0

I'm trying to create a LinearLayout with the left view width being 80% of its parents width and the second view taking up the remaining space. How do I accomplish this?

enter image description here

Community
  • 1
  • 1
CodePrimate
  • 6,646
  • 13
  • 48
  • 86
  • Take a look here : http://stackoverflow.com/questions/4961355/percentage-width-in-a-relativelayout It's about the same problem – thomas-hiron Jan 19 '13 at 15:21

2 Answers2

0

Trying using android:layout_weight when defining your child Views.

For view 1 use a layout weight of 0.8 and view 2 use a layout weight of 0.2

Example xml would be :

android:layout_weight=".8"
yarakyo
  • 499
  • 3
  • 6
0

Like this:

Don't forget to set the width to 0.

<TextView
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight=".8"
    android:background="@color/blue" />

<TextView
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight=".2"
    android:background="@color/red" />

G. Blake Meike
  • 6,615
  • 3
  • 24
  • 40