加入利润率高于顶ListView项(和低于上年)的安卓 [英] Add margin above top ListView item (and below last) in Android

查看:164
本文介绍了加入利润率高于顶ListView项(和低于上年)的安卓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是有关项目在Android的一个ListView布局中的pretty的罚款问题。

This is a pretty fine question about the layout of items in a ListView in Android.

我有在顶部标题栏和一个ListView占用屏幕的其余部分的活动。我希望我的ListView出现与10dp填充在左,右和上,但是当你滚动的ListView了,我希望它的消失边缘下消失前盖顶10dp填充。同样,当您滚动至底部,最后一个列表项应出现10dp最后一个列表项的底部和屏幕的实际底部(介乎如果你想知道为什么,那是因为有一个pretty的背景图片我想戳围绕ListView控件)。

I have an activity with a title bar at the top and a ListView taking up the rest of the screen. I want my ListView to appear with 10dp padding on the left, right and top, but when you scroll the ListView up, I want it to cover the top 10dp padding before disappearing under the faded edge. Similarly, when you scroll to the bottom, the last list item should appear with 10dp between the bottom of the last list item and the actual bottom of the screen (if you're wondering why, it's because there's a pretty background image that I want poking out around the ListView).

我试着添加填充到ListView本身,但是当你滚动列表,它填充的下边缘就会消失。

I've tried adding padding to the ListView itself, but then when you scroll the list it disappears under the edge of the padding.

我是从一个网站开发背景,以及类比是增加保证金上面第一个列表项(与下面的最后一个列表项)。

I'm from a web dev background, and the analogy would be to add margin above the first list item (and below the last list item).

推荐答案

您写的:

我试着添加填充到ListView本身,但是当你滚动列表,它填充的下边缘就会消失。

I've tried adding padding to the ListView itself, but then when you scroll the list it disappears under the edge of the padding.

设置 ListView的 clipToPadding 属性。这将使周围的的ListView填充 滚动到布局的结束(和不仅要填充的边缘)。

Set ListView's clipToPadding attribute to false. This will enable padding around the ListView and scrolling to the end of the layout (and not only to the edge of the padding).

一个例子:

<ListView
    android:id="@+id/list_view"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:divider="@android:color/transparent"
    android:dividerHeight="10.0sp"
    android:padding="16dip"
    android:clipToPadding="false"/>

安卓clipToPadding 是<一个XML属性href="http://developer.android.com/reference/android/view/ViewGroup.html#attr_android%3aclipToPadding"><$c$c>ViewGroup,基类的布局和视图的容器。

android:clipToPadding is an XML attribute of ViewGroup, the base class for layouts and views containers.

相关<一href="http://developer.android.com/reference/android/view/ViewGroup.html#setClipToPadding%28boolean%29">method拨打是:

public void setClipToPadding (boolean clipToPadding)

这篇关于加入利润率高于顶ListView项(和低于上年)的安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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