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

  • Home
  • SEARCH
  • 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 3286454
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:22:55+00:00 2026-05-17T20:22:55+00:00

<?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent > <TextView android:text=Title android:id=@+id/TextView01 android:layout_width=wrap_content android:layout_height=wrap_content

  • 0
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    >

<TextView 
    android:text="Title" 
    android:id="@+id/TextView01" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textSize="30px" 
    android:textStyle="bold" 
    >
</TextView>

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="60px">

<Button 
    android:text="Choose a Story" 
    android:id="@+id/choose" 
    android:layout_width="150px" 
    android:layout_height="wrap_content"  
    android:layout_gravity="bottom" 
    android:layout_marginBottom="1px">
</Button>

<Button 
    android:text="Info" 
    android:id="@+id/info" 
    android:layout_width="150px" 
    android:layout_height="wrap_content"  
    android:layout_gravity="bottom" 
    android:layout_marginBottom="1px">
</Button>

</LinearLayout>
</LinearLayout>

In this code, as you can see, there is a title, 2 linear layouts, and 2 buttons that are inside a linear layout. What I’m trying to do is center the 2 buttons. No matter what I do, I can never get the 2 buttons to be centered at the bottom with a height of 60px.

In the end I’m trying to make the text centered both vertically and horizontally, and have the 2 buttons on the bottom centered horizontally. What do I need to change?

Heres a picture of what it looks like in the Layout Editor.
alt text

  • 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-05-17T20:22:56+00:00Added an answer on May 17, 2026 at 8:22 pm

    On your inner linear layout, set the layout_gravity.

    Here’s one solution

    <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout 
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        >
    <TextView 
        android:text="Title" 
        android:id="@+id/TextView01" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textSize="30dip" 
        android:textStyle="bold" 
        />
    
        <LinearLayout 
            android:orientation="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="60dip"
            android:layout_gravity="bottom|center_horizontal"
            android:layout_marginBottom="1dip"
            >
    
        <Button 
            android:text="Choose a Story" 
            android:id="@+id/choose" 
            android:layout_width="0dip" 
            android:layout_height="wrap_content"
            android:layout_weight="1"
            />
    
        <Button 
            android:text="Info" 
            android:id="@+id/info" 
            android:layout_width="0dip"
            android:layout_weight="1" 
            android:layout_height="wrap_content"
            />
    
        </LinearLayout>
    </FrameLayout>
    

    In general, you should style the outermost component (container) which will then position all of its children accordingly. As a side not, this layout would be achieved using just a single (or pair, depending on exactly what you’re trying to do) or FrameLayouts, which would significantly reduce the layout overhead. While there’s nothing wrong with LinearLayout, it is surprisingly computationally expensive.

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

Sidebar

Related Questions

<?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent android:background=@drawable/bkgrnd> <RelativeLayout android:id=@+id/RelativeLayout01 android:layout_width=wrap_content android:layout_height=wrap_content >
main.xml: <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent > <TextView android:text=@+id/customText android:id=@+id/customText android:layout_width=wrap_content
Here is my layout <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:id=@+id/LinearLayout01 android:layout_height=wrap_content> <Spinner android:text=@+id/AutoCompleteTextView01
I've the following layout <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent android:background=@color/all_white android:gravity=center>
Here's my xml: <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=fill_parent android:orientation=vertical> <RelativeLayout android:layout_width=fill_parent android:layout_height=wrap_content
Here is my layout: <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=fill_parent android:orientation=vertical> <ListView android:layout_height=wrap_content
I've got the following layout: <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=wrap_content android:orientation=vertical> <WebView
I have a simple layout: <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent> <LinearLayout
I've tried this code: <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent> <LinearLayout android:orientation=horizontal
My main.xml looks like this: <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent >

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.