What does Relative layout wrap_content do?

I have a simple layout as follows. Even though, I set all attributes as wrap_content, the resulting layout fills the entire screen height wise. The individual layouts in themselves are small. So the top level container should only be as big as to wrap all its elements. But it seems to fill the full screen. Width wise, the same attributes work fine. What am I missing here?

<LinearLayout
android:id="@+id/lowercontainer"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="10dip"
android:layout_centerHorizontal="true"
android:paddingLeft="0dip"
android:paddingRight="0dip"
android:layout_alignParentBottom="true"
android:background="@drawable/solid_blue"
>

 <ImageView
 android:id="@+id/lefticon"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content" 
 android:background="@drawable/ic_settings_display"
 android:layout_alignParentLeft="true"
 android:layout_alignParentBottom="true"
 android:paddingRight="0dip"
 /> 

  <ImageView
 android:id="@+id/righticon"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content" 
 android:background="@drawable/ic_settings_display"
 android:layout_alignParentRight="true"
 android:layout_alignParentBottom="true"
 android:paddingLeft="0dip"
 /> 

</LinearLayout>

 <TextView android:id="@+id/test"
    android:text="Test text"
    android:textStyle="bold"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:paddingTop="10dip"
    android:gravity="center"
    android:layout_centerHorizontal="true"
    android:textSize="20dip"
    android:layout_above="@id/lowercontainer"
    android:background="@drawable/solid_green"
    />         

Answers


It is the android:layout_alignParentBottom="true" in your LinearLayout that is causing the RelativeLayout to stretch all the way to the bottom of the screen.


Need Your Help

How can I install the new iOS SDK on Xcode 5?

ios xcode xcode5 itunes

How can I install the new iOS SDK on Xcode 5 to be able to compile applications for the new iOS on Xcode 5? I've tried to use iTunes to transfer compiled applications to the device. But it doesn't ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.