14

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

Keith Adler
  • 20,880
  • 28
  • 119
  • 189

1 Answers1

15

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

louiscoquio
  • 10,638
  • 3
  • 33
  • 51