views:

43

answers:

1

Hello.

I'm very very new on Android.

I want to put a TextView inside a LinearLayout that fills the 80% of LinearLayout's height.

How can I do that? or How can assign percentage on Widht and Height?

Thanks.

+2  A: 

A layout like this will work. The key is the layout_weight attribute. Android's documentation is not very good for that attribute. Note that the second TextView (it could be anything) is required otherwise, the first TextView will take up the whole space.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
   <TextView android:layout_weight="0.8"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    android:background="#FFC300"
    />
    <TextView android:layout_weight="0.2"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:text="second text box"
     />
</LinearLayout>
ageektrapped