机器人的ListView页脚查看没有被放置在屏幕的底部 [英] Android ListView Footer View not being placed on the bottom of the screen

查看:164
本文介绍了机器人的ListView页脚查看没有被放置在屏幕的底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我敢肯定,我失去了一些东西简单的得到这个实现的,但通过每一个已知的组合,我可以拿出来得到什么,我希望做的工作运行。我想有一个ListView页脚坐在屏幕底部时的ListView项目不填充页面。

I'm sure that I'm missing something simple to get this implemented, but have run through every known combination I can come up with to get what I'm looking to do working. I'm trying to have a ListView footer sit at the bottom of the screen when the ListView items do not fill the page.

例如,我有三个项目一个ListView和FooterView(使用ListView的addFooterView)我想这footerView坐在屏幕底部的页面。当ListView控件包含足够的项目滚动屏幕时,footerView应该坐在列表(而不是在屏幕的底部)。

For example, I have a page with a ListView of three items and a FooterView (using the ListView's addFooterView) I want that footerView to sit at the bottom of the screen. When the ListView contains enough items to scroll the screen, the footerView should sit at the end of the list (not at the bottom of the screen).

我试图使用XML列如下。任何和所有帮助是非常AP preciated!

The XML I'm trying to use is listed below. Any and all help is much appreciated!

Layout.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>

ListViewRow.xml

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>

ListViewFooter.xml

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>

Java的

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);

我到目前为止已经试过的东西包括:

The things I've tried so far include:

  • 添加页脚视图作为上述
  • 添加绘制资源作为在ListView一个背景(这造成在ListView不跨越屏幕的整个宽度和在奇方式滚动由于9-修补伸缩区域)
  • 添加cone_footer在布局一个单独的视图

在此先感谢!

推荐答案

在其他情况下,都在寻找一个类似的答案,这里是我最后做来解决这个问题我有。由于页脚我一直在寻找增加是仅仅只是一个形象来填充屏幕一些空间(因为当观点是短期),和ListView控件的方法是不是真的是我需要我的实现,我们结束了这作为我们的XML布局:

In case others are looking for a similar answer, here is what I ended up doing to solve the issue I had. Since the "Footer" I was looking to add was merely just an image to fill some space in the screen (for when views were short), and the ListView approach wasn't really what I needed for my implementation, we ended up with this as our XML layout:

    <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res/com.example.android.apis"
    style="@style/company.mainContainer">

    <LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical">
        <!-- enter page content here -->

        <View android:layout_height="0px" android:layout_weight="1"
            android:visibility="invisible" />

        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|right"
            android:scaleType="fitXY"
            android:src="@drawable/footer_cone">
        </ImageView>

    </LinearLayout>

</ScrollView>

希望这有助于其他人!

Hope this helps others!

这篇关于机器人的ListView页脚查看没有被放置在屏幕的底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆