Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8353419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:15:11+00:00 2026-06-09T09:15:11+00:00

I have a TextView and 3 Buttons centered in a RelativeLayout , and the

  • 0

I have a TextView and 3 Buttons centered in a RelativeLayout, and the text in all three of them is left-justified with the parent center as the leftmost line.

I’ve tried changing the gravity of the TextView, Buttons, and layout but nothing is working and I’m baffled because I’ve never seen Android align text like this before.

I want the Button text to be centered within each Button and the top text to be center-justified.

An image of what it looks like is here: https://i.stack.imgur.com/9lHEd.png

Here’s my xml:

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView
    android:id="@+id/textView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_margin="20dp"
    android:gravity="center_horizontal"
    android:text="@string/greeting"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<Button
    android:id="@+id/startQuizButton"
    android:layout_width="280dp"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView1"
    android:layout_centerHorizontal="true"
    android:onClick="@string/startQuiz"
    android:text="@string/start_quiz" />

<Button
    android:id="@+id/lessonsButton"
    android:layout_width="280dp"
    android:layout_height="wrap_content"
    android:layout_below="@+id/startQuizButton"
    android:layout_centerHorizontal="true"
    android:onClick="@string/startLesson"
    android:text="@string/lessonsString" />

<Button
    android:id="@+id/viewAllButton"
    android:layout_width="280dp"
    android:layout_height="wrap_content"
    android:layout_below="@+id/lessonsButton"
    android:layout_centerHorizontal="true"
    android:onClick="@string/showAll"
    android:text="@string/view_all" />

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T09:15:13+00:00Added an answer on June 9, 2026 at 9:15 am

    I included a RelativeLayout because you have it as your parent layout. However, i am not sure that it is needed. See if the following code is what you are looking for.

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" >
    
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center_horizontal"
                android:text="Greetings" />
    
            <Button
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Start Quiz" />
    
            <Button
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Lessons" />
    
            <Button
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="View all questions" />
        </LinearLayout>
    
    </RelativeLayout>
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 9 (programmatically generated) buttons. I do this for all of them: Button
I have a custom ListView in which there are 2 buttons and a textview
Typical search layout having RelativeLayout, TextView, EditText and Button I have a.9.png image having
I have a textView and text like This is the Simple Text with KeyWord
I have a TextView which i set the text using setText(). In properties, I
I want to have a TextView on the left that fills space, plus a
I have a problem with centering text on buttons in a layout that I
I have an activity with two Buttons and a TextView in a LinearLayout. My
I have a header with two buttons and one textview one button is aligned
I have created linearlayout with layout:height=fill_parent I have set 3 buttons and one TextView.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.