【发布时间】:2017-01-12 17:26:34
【问题描述】:
我正在开发一个安卓应用。 我的主要活动中有多个导航抽屉。它们的定义如下:
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/drawer_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"/>
<ListView android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="fill_parent"
android:layout_gravity="left"
android:choiceMode="singleChoice"
android:divider="@android:color/black"
android:dividerHeight="5dp"
android:background="#e1fcff"
/>
<ListView android:id="@+id/right_drawer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="end"
android:choiceMode="singleChoice"
android:divider="@android:color/black"
android:dividerHeight="5dp"
android:background="#e1fcff"
android:layout_marginLeft="-64dp"
/>
<ListView android:id="@+id/contacts_drawer_right"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="end"
android:choiceMode="singleChoice"
android:divider="#ffff2a00"
android:dividerHeight="5dp"
android:background="#e1fcff"
android:layout_marginLeft="-64dp"
/>
我在“contacts_drawer_right listview”中填充了一个RelativeLayout,它的内部也有一个listView(id=contactsListView)。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical"><ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/contactsListView"
/>
</ScrollView>
</RelativeLayout>
我的问题是,contactsListView 没有填充它的父高度,尽管我在它的定义布局文件中使用了android:layout_height="fill_parent"。
我的期望如下:
enter image description here
但实际情况如下:enter image description here
而且我也不能滚动列表视图。
请给我一些想法并告诉我如何显示我的列表视图的所有内容(带有填充的父项)。
【问题讨论】: