Layout Weight In Linear Layout Android?
Solution 1:
I can't tell if this is your only problem yet but when you use layout_weight
inside of a vertical LinearLayout
then your layout_height
should be 0dp
.
Likewise if it is inside of a horizontal LinearLayout
then the layout_width
should be 0dp
. Also, all of the layouts
should have a weight
if you are using it on one of thenm.
android:layout_below=
in your third LinearLayout
, I believe, is not a property of LinearLayout
. That is a property of RelativeLayout
.
My suggestion for this type of setup is to use RelativeLayout
as the root layout
. Then, for your header LinearLayout
you can use android:layout_alignParentTop="true"
and for your footer use android:layout_alignParentBottom="true"
then stick your ListView
in the middle with android:layout_below="@id/idOfHeaderLL"
<RelativeLayout...><LinearLayoutandroid:id="@+id/headerLL"android:layout_alignParentTop="true"...><!-- add header veiws -->
</LinearLayout
<ListViewandroid:layout_below="@id/headerLL".../><LinearLayoutandroid:layout_alignParentBottom="true"...><!-- add footer views --></LinearLayout></RelativeLayout>
I'm not going to rewrite the whole layout but that should give you an idea. The "..." is where you will put in your other properties such as height, width, etc...
Post a Comment for "Layout Weight In Linear Layout Android?"