listview with header和stackFromBottom设置为true

时间:2015-04-05 00:24:38

标签: android listview

我有一个ListView,我正在向其中填充标题视图,

 getListView().addHeaderView(headerView);

我遇到的问题是,当我设置stackFromBottom =" true"除了标题之外没有任何项目,它在列表的底部绘制,它看起来像标题只是列表中的另一个项目。

当列表中没有项目时,是否可以将标题保持在顶部?

ListView XML

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/lId"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >


    <ListView
        android:id="@id/android:list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/form"
        android:layout_alignParentTop="true"
        android:cacheColorHint="@android:color/transparent"
        android:divider="@null"
        android:dividerHeight="10dp"
        android:footerDividersEnabled="true"
        android:headerDividersEnabled="true"
         android:listSelector="@android:color/transparent"
        android:transcriptMode="alwaysScroll" />
</RelativeLayout>

标题

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:descendantFocusability="beforeDescendants"
    android:paddingLeft="5dp"
    android:paddingRight="5dp" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:descendantFocusability="afterDescendants"
        android:orientation="vertical">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp" >

            <ImageView
                android:id="@+id/imgV1"
                android:layout_width="70dp"
                android:layout_height="70dp"
                app:border_width="4dp" />


        </RelativeLayout>


    </LinearLayout>

</FrameLayout>

0 个答案:

没有答案