【发布时间】:2017-03-02 10:35:22
【问题描述】:
我在 listview 上平滑滚动时遇到了奇怪的行为。 我在列表中有 30 项。当我通过
平滑滚动时listview.smoothScrollToPositionFromTop(29, 0);
屏幕末尾会有一些额外的空间。实际上 listview 向上移动了一点。图片附在下面。但是如果我手动滚动就没有空间了。可以做些什么来解决这种行为?
这是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_orange_light">
<ListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
【问题讨论】:
-
在布局中:
android:padding="0px" android:margin="0px" -
只需删除 listview.smoothScrollToPositionFromTop(29, 0);
-
@LunarWatcher 问题仍然存在,填充和边距为零
-
@JaiminModi 我故意想要平滑滚动到第 29 项。
-
嗨,我也有同样的问题。