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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:56:01+00:00 2026-05-26T01:56:01+00:00

Can somebody please explain why layout is much bigger than button vertically. Im using

  • 0

Can somebody please explain why layout is much bigger than button vertically. Im using WRAP_CONTENT for the layout height. Also Second button just disappeared.

Layout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="#f00"
    >
    <Button  
        android:id="@+id/Button01"  
        android:text="Button One big button"  
        android:layout_width="wrap_content"   
        android:layout_height="wrap_content"></Button>
    <Button  
        android:id="@+id/Button02"  
        android:text="Button Two"
        android:layout_toLeftOf="@id/Button01"   
        android:layout_width="wrap_content"   
        android:layout_height="wrap_content"></Button>
</RelativeLayout>

enter image description here

I can see that it is because of using layout_toLeftOf tag with a anchor view (Button 01) whose position width wise is not precisely defined. Im looking for more insights here. Can anybody chip in??

Thanks in advance.

EDIT:

  • Why does Button 2 disappear : Quiroga has put down a good answer below
  • Why Layout height increase : Experimets reveal that its because
    of Button02 width!! Platform has pushed the button 02 to the invsible space on the left of the layout but squeezed it to a single char width. For exmaple if the change the text of the buton 02 as follows

    android:text=”Btn 2″

    Then output changes to (height of layout reduced)
    enter image description here

So the bottom line — Make sure to use right alignment parameters. Else some of your views might disappear and worse layout appearance can be hugely different from what you expect!

  • 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-26T01:56:02+00:00Added an answer on May 26, 2026 at 1:56 am

    Change to this:

       <Button  
            android:id="@+id/Button02"  
            android:text="Button Two"
            android:layout_toRightOf="@id/Button01"   
            android:layout_width="wrap_content"   
            android:layout_height="wrap_content"></Button>
    

    I think you missunderstand the layout_toLeftOf param .

    Which makes your first button stay this image way (Using layout_toLeftOf ):

                 |<-- R Layout width-->| 
      |Button Two|Button One big button|
                 |                     |
                 |_____________________|
    

    And in order to understand the issue , i explain it (but maybe i’m wrong ):

    Layout put in the RelativeLayout , the first Elements it see in the XML file. Then if you put wrap_content in the button and in the RelativeLayout you put the same , it first measure the size of it and put it in then . Aligning it by default to the left upper placer , and setting the RelativeLayout width fixed when it sees that there is nothing mre in the right, down direction.

    P.S: And yes , you can put an element out of the screen 😉

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

Sidebar

Related Questions

Can somebody please explain me clearly by using some nice examples how c++ class
Can somebody please explain how to use macros in x86 assembly coding
Can somebody please explain how to find out if full text search is enabled
Can somebody please explain what does this warning mean: undefined reference to 'WinMain@16' ?
Can somebody please explain why a while statement like while (ch != '\n' ||
can somebody please explain what does it mean : passing arg 1 of 'free'
Can somebody please explain this IE7 bug to me? It occurs in Standards and
can somebody please explain, I have a program on C, can I convert it
can somebody please explain what is the difference between freeglut.h and glut.h
can somebody please explain is it possible to convert this snippet of the code

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.