Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android fill percent of layout

Tags:

android

layout

How do I make elements in a layout occupy 50, 25, 10, etc. percent of the horizontal/vertical space available?

like image 684
Keith Adler Avatar asked Jun 30 '11 21:06

Keith Adler


1 Answers

You could achieve this with something like that : ( for vertical here )

<LinearLayout 
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="0dip"
    android:weightSum="100">
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="60">
    </LinearLayout>
</LinearLayout>`

See android:weightsum documentation

like image 135
louiscoquio Avatar answered Nov 07 '22 13:11

louiscoquio