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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:41:26+00:00 2026-06-17T14:41:26+00:00

In my app I have a screen with four buttons, aligned one on top

  • 0

In my app I have a screen with four buttons, aligned one on top of the other. The text of these buttons depends on what the user has entered, so I do not know which button is the biggest.

I want to align them so that the left sides of the buttons are all aligned with the widest button, and the right sides of the buttons are all aligned with the right side of the widest button.

To solve my problem I wrote this:

    int biggestWidth=buttonA.getWidth();

    if(biggestWidth<buttonB.getWidth()){//if the width of button b is bigger than the width of button a

        biggestWidth = buttonB.getWidth();

    } if(biggestWidth<buttonC.getWidth()){

        biggestWidth = buttonC.getWidth();

    } if (biggestWidth<buttonD.getWidth()){

        biggestWidth= buttonD.getWidth();
    }
buttonA.setWidth(biggestWidth);
    buttonB.setWidth(biggestWidth);//sets all the buttons to the width of the biggest one
    buttonC.setWidth(biggestWidth);
    buttonD.setWidth(biggestWidth);

But this is not working, because the edges of the buttons are all aligned with the edges of the first button, rather than the edges of the one with the most text. Does anyone know/think they know where I am going wrong?

  • 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-17T14:41:27+00:00Added an answer on June 17, 2026 at 2:41 pm

    Try with this layout pattern :

    <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical" >
    
            <Button
                android:id="@+id/button1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="show" />
    
            <Button
                android:id="@+id/button2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="show123" />
    
            <Button
                android:id="@+id/button3"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="show12345686" />
    </LinearLayout>
    

    Thanks.

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

Sidebar

Related Questions

My app needs to have multiple screen e.g. one login page then another page
I have develop one universal app. I have four type images iphone - simple.png
In my android app I have a login screen. A graphic designer has given
I have develop one app in which four box question are there. all question
In my app I have a screen where I display some text and then
In my Swing app, I have a screen that has a bunch of JTextFields.
I have a screen that has a few images and one of them has
in my app I have a preview screen. On one device (LG, with Android
I want to add image buttons on my main app screen that have a
In my app I have four tabs in the bottom of my main screen.

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.