ListView下方的Android View元素

时间:2014-06-11 22:28:06

标签: android listview layout

我意识到还有一些其他帖子围绕这个问题,但没有一个似乎解决了我的问题。基本上我有一个导航抽屉,其相对布局封装了标准列表视图。在这个相对布局中有两个列表视图,一个是大小和内容通过CursorLoader和自定义CursorAdapter动态变化,另一个是谁的元素是固定的。我之所以这样设计它是因为我无法找到一种简单的方法来将节标题放入列表视图中。请注意我正在使用的抽屉布局文件:

<?xml version="1.0" encoding="utf-8"?>

<!-- The main content view -->

<FrameLayout
    android:id="@+id/content_frame"
    android:layout_width="wrap_content"
    android:layout_height="match_parent" >
</FrameLayout>

<!-- The navigation drawer -->

<RelativeLayout
    android:id="@+id/left_drawer"
    android:layout_width="250dp"
    android:layout_height="wrap_content"
    android:layout_gravity="start"
    android:background="@color/dark_gray_opaque_20"
    android:padding="10dp" >

    <ImageView
        android:id="@+id/drawer_logo"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/western_purple"
        android:contentDescription="@string/app_name"
        android:padding="10dp"
        android:src="@drawable/ic_logo_wide" />

    <ListView
        android:id="@+id/drawer_modules"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/drawer_logo"
        android:choiceMode="singleChoice"
        android:divider="@color/western_purple"
        android:dividerHeight="2dp" />

    <TextView
        android:id="@+id/drawer_customize"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/drawer_modules"
        android:paddingTop="30dp"
        android:text="@string/drawer_your_western"
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <ListView
        android:id="@+id/drawer_personal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/drawer_customize"
        android:choiceMode="singleChoice"
        android:divider="@color/western_purple"
        android:dividerHeight="2dp" >
    </ListView>
</RelativeLayout>

这一切都适用于一些项目但是当列表视图变得比屏幕大时,第一个列表视图下面的所有内容都不再显示。有人可以提供任何指导吗?或者建议使用自定义适配器,提供程序和游标加载器将段标题放入列表视图的替代方法,而不将标题本身放入数据库中?

1 个答案:

答案 0 :(得分:0)

不要让你的顶级ListView的高度wrap_content,将其限制在dp中的某个值,否则它会尽可能大。