Android TextView占据了80%的屏幕

Android TextView占据了80%的屏幕,android,layout,Android,Layout,我对Android非常陌生 我想在LinearLayout中放置一个文本视图,该视图填充LinearLayout高度的80% 我该怎么做?或者如何分配宽度和高度的百分比 谢谢。像这样的布局就行了。关键是布局权重属性。Android的文档对于这个属性不是很好。请注意,第二个TextView(可以是任何内容)是必需的,否则,第一个TextView将占用整个空间 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/and

我对Android非常陌生

我想在LinearLayout中放置一个文本视图,该视图填充LinearLayout高度的80%

我该怎么做?或者如何分配宽度和高度的百分比


谢谢。

像这样的布局就行了。关键是布局权重属性。Android的文档对于这个属性不是很好。请注意,第二个TextView(可以是任何内容)是必需的,否则,第一个TextView将占用整个空间

<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>