根据屏幕高度设置布局
问题描述:
我在屏幕中使用了两个ListView。我想分割每个ListView的高度,但我希望它是独立于屏幕的。为此,我需要知道屏幕的高度。我正在使用XML来做到这一点。 任何人都可以帮助我做到这一点?根据屏幕高度设置布局
谢谢 迪帕克
答
试试这个:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
</LinearLayout>
重要的部分有ListViews
android:layout_height="fill_parent"
和android:layout_weight="1"
和LinearLayout
android:orientation="vertical"
Documentation了解更多关于layout_weight属性的信息。
答
试的意见“补父”和布局重布局的高度设置为1