当我创建一个简单的布局,它只是一个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.
上一篇:燮preSS&QUOT;资源名称是不是有效的标识符&QUOT;标识符、名称、有效、资源
下一篇:Android的工作室1.0.2新项目 - 无法解析符号“ActionBarActivity”新项目、符号、工作室、Android