android - View widthXheight equals to the available space of the screen -
i'm creating layout
, have header aligned on top, footer aligned on bottom , want view take rest of available space in middle.
how do without explicit passing height attributes each view?
my actual xml is:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" orientation="vertical"> <imageview android:id="@+id/header" android:layout_width="match_parent" android:layout_height="wrap_content" android:src="@drawable/library_header" android:scaletype="fitxy" /> <viewflipper android:id="@+id/content" android:layout_height="0dip" android:layout_width="match_parent" android:layout_weight="1.0" /> <linearlayout android:layout_width="match_parent" android:layout_height="44px" android:layout_alignparentbottom="true" android:background="@drawable/library_footer"> <button android:id="@+id/l_coverflow" android:layout_width="44px" android:layout_height="34px" android:background="@drawable/library_coverflow_deselected" android:layout_gravity="center" android:layout_marginleft="12px" /> <button android:id="@+id/l_grid" android:layout_width="36px" android:layout_height="32px" android:background="@drawable/library_grid_deselected" android:layout_marginleft="12px" android:layout_gravity="center" android:paddingleft="10px" /> <button android:id="@+id/l_list" android:layout_width="40px" android:layout_height="32px" android:background="@drawable/library_list_deselected" android:layout_marginleft="12px" android:layout_gravity="center" /> </linearlayout> </linearlayout>
it's easy (i omitted android: namespace prefix brevity):
<linearlayout orientation="vertical" layout_width="fill_parent" layout_height="fill_parent"> <!-- header goes here height=wrap_content --> <middleview layout_width="fill_parent" layout_height="0dip" layout_weight="1.0" /> <!-- footer goes here height=wrap_content --> </linearlayout>
Comments
Post a Comment