我在屏幕中使用了兩個ListView。我想分割每個ListView的高度,但我希望它是獨立於屏幕的。爲此,我需要知道屏幕的高度。我正在使用XML來做到這一點。 任何人都可以幫助我做到這一點?根據屏幕高度設置佈局
謝謝 迪帕克
我在屏幕中使用了兩個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