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 755483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:08:06+00:00 2026-05-14T15:08:06+00:00

I have this XML code which generates a button, a textview and another button,

  • 0

I have this XML code which generates a button, a textview and another button, How do I go about getting the button to appear in far left, the textview in the center and the last button on the far right?

<?xml version="1.0" encoding="utf-8"?>  
<LinearLayout android:id="@+id/LinearLayout01"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    xmlns:android="http://schemas.android.com/apk/res/android">

    <Button android:id="@+id/Button01" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="Cancel">
    </Button>
    <TextView android:id="@+id/TextView01" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="New Place">
    </TextView>
    <Button android:id="@+id/Button03" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Save">
     </Button>

</LinearLayout>
  • 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-14T15:08:07+00:00Added an answer on May 14, 2026 at 3:08 pm

    You need to use the weight property. Think of it as letting android know the percentage of width it should give each item.

    you need to set width to 0dip for all the 3 items and add the weight property

        <Button android:id="@+id/Button01" 
                  android:layout_width="wrap_content" 
                  android:layout_height="wrap_content" 
                  android:text="Cancel"
                  android:layout_width="0dip" 
                  android:layout_weight="2" >
          </Button>
          <TextView android:id="@+id/TextView01" 
                    android:layout_width="wrap_content" 
                    android:layout_height="wrap_content" 
                    android:text="New Place"
                    android:layout_width="0dip" 
                    android:layout_weight="1" >
          </TextView>
          <Button android:id="@+id/Button03" 
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:text="Save"
                  android:layout_width="0dip" 
                  android:layout_weight="2" >
          </Button>
    

    Play around with the weight value and you will understand how it works 🙂

    After this you can use the gravity property to move text to center / left or right.

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

Sidebar

Related Questions

I currently have this code which stores XML into an XML-type column called data,
I have the following code which generates XML: $dom = new DomDocument('1.0'); ...snip adding
I have an XML layout similar to this (the XML and code is a
OK I have this layout in XML & and this code, what I am
I have this code that reads from XML file. It gets five strings (groupId,
I have this test code that just saves an XML file to a folder.
I have this below code and it work fine header (content-type: text/xml); $xml =
I have this code: ... request data = new request(); data.username = formNick; xml
I have code like this: // Take the xml message and turn it into
I have got this code for detection of mobile device. <?xml version=1.0 encoding=UTF-8?> <configuration>

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.