相关疑难解决方法(0)

Android ListView页脚视图未放置在屏幕底部

我确信我错过了一些简单的方法来实现这一点,但是我已经完成了所有已知的组合,以便得到我正在寻找的工作.当ListView项目没有填满页面时,我正试图让ListView页脚位于屏幕底部.

例如,我有一个包含三个项目的ListView的页面和一个FooterView(使用ListView的addFooterView)我希望footerView位于屏幕的底部.当ListView包含足够的项目来滚动屏幕时,footerView应该位于列表的末尾(而不是位于屏幕的底部).

我正在尝试使用的XML如下所示.任何和所有的帮助非常感谢!

Layout.xml

<?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:background="@+drawable/background">
<ListView
    android:id="@+id/menu" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:listSelector="@android:color/transparent"
    android:divider="@null">
</ListView></RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

ListViewRow.xml

<?xml version="1.0" encoding="utf-8"?><LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
style="@style/Nationwide.menu">
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/nav_item"
    style="@style/Nationwide.menu.row">
    <ImageView 
        android:id="@+id/image_icon"
        style="@style/Nationwide.menu.leftIcon" />
    <TextView 
        android:id="@+id/nav_text" 
        style="@style/Nationwide.menu.text" />
    <ImageView
        android:id="@+id/chevron_symbol"
        style="@style/Nationwide.menu.rightIcon" />
</LinearLayout>
<View
    android:layout_height="1dp"
    android:background="@drawable/nav_item_divider_dark" />
<View
    android:layout_height="1dp"
    android:background="@drawable/nav_item_divider_light" /></LinearLayout>
Run Code Online (Sandbox Code Playgroud)

ListViewFooter.xml

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true">
<View 
    android:id="@+id/footer_image"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentBottom="true" /></RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

Java的

    LayoutInflater inflater = this.getLayoutInflater();
    View footerView = inflater.inflate(R.layout.footer, null);

    footerView.findViewById(R.id.footer_image).setBackgroundDrawable(resources.getDrawable(R.drawable.cone_footer));

    mMenuListView.addFooterView(footerView);
Run Code Online (Sandbox Code Playgroud)

到目前为止我尝试过的事情包括:

  • 添加页脚视图如上所示
  • 在ListView上添加可绘制资源作为背景(这导致ListView不会跨越屏幕的整个宽度,并且由于9-Patch可伸缩区域而以奇怪的方式滚动) …

android listview footer

15
推荐指数
2
解决办法
2万
查看次数

带有页眉和页脚按钮的Android列表视图

乡亲!我需要做这样的布局:我有listview,我需要把按钮放在它的顶部和底部,即当用户滚动列表到最后,他可以看到底部按钮,当用户在顶部时列表,他可以看到顶部按钮.但是当用户处于listview的"中间"时,他看不到这些按钮.我不知道该怎么做.感谢帮助.

UPDATE

listView=(ListView)findViewById(R.id.listSearchResults);

        LayoutInflater inflater=this.getLayoutInflater();

        View header=inflater.inflate(R.layout.list_header, null);

        btnBack=(Button)header.findViewById(R.id.btnBack);
        btnBack.setOnClickListener(this);
        btnBack.setEnabled(false);

        listView.addHeaderView(header);

        View footer=inflater.inflate(R.layout.list_footer, null);

        btnForward=(Button)footer.findViewById(R.id.btnForward);
        btnForward.setOnClickListener(this);
        btnForward.setEnabled(false);
        listView.addFooterView(footer);
Run Code Online (Sandbox Code Playgroud)

android android-layout

6
推荐指数
2
解决办法
3万
查看次数

标签 统计

android ×2

android-layout ×1

footer ×1

listview ×1