分离器(分)的ListView的最后一个项目后, [英] Separator (divider) after last item of ListView

查看:158
本文介绍了分离器(分)的ListView的最后一个项目后,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我创建一个简单的布局,它只是一个ListView,有的最后一个项目,它看起来有点后显示没有分隔难看。

When I create a simple layout with only a ListView in it, there is no separator displayed after the last item, which looks a bit ugly.

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

    <ListView
        android:id="@android:id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true" />
</RelativeLayout>

不过,我发现了一个分隔符的是如果我添加另一种观点波纹管的ListView和设置安卓显示的最后一个项目之后:layout_above 属性的列表视图。

However, I found out that a separator is displayed after the last item if I add another view bellow the listview and set the android:layout_above attribute for the listview.

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

    <ListView
        android:id="@android:id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/bottom"
        android:layout_alignParentTop="true" />

    <TextView
        android:id="@+id/bottom"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="@android:color/holo_blue_dark"
        android:text="Bottom" />
</RelativeLayout>

为什么在列表视图这样的表现?我怎样才能在只包含一个ListView布局的最后一个项目后隔板?

推荐答案

答案很简单:你应该改变安卓layout_height =WRAP_CONTENT机器人:layout_height =match_parent的ListView

The answer is very simple: you should change android:layout_height="wrap_content" to android:layout_height="match_parent" in your ListView.

您可能已经猜到为什么会这样。

You can probably guess why this happens.

这篇关于分离器(分)的ListView的最后一个项目后,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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