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

Why are negative while loops so fast?

javascript performance loops while-loop repeat

I'm working on a library specifically for Utilities. It will have functions that help you manipulate: Strings, Arrays, Numbers, Objects, and more. Performance is a main focus. While working on the ...

What is threading context?

c# java multithreading synchronization

Does a thread's context refer to a thread's personal memory? If so, how is memory shared between multiple threads?

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.