【发布时间】:2014-05-24 01:00:42
【问题描述】:
SwipeRefreshLayout 在 v19.1.0 中被添加到 Android 支持库中: https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html
我现在已将它添加到我的应用程序中,它可以像宣传的那样工作。但是,如果我慢慢滑动,我会注意到过度滚动非常生涩。观看此视频以了解我的意思: https://www.youtube.com/watch?v=HAuadMZYRf0
我发现问题是使用复杂程度不同的多种布局。上面链接的视频中显示的布局是:
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_refresh_widget"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
以及相关的Java代码:
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
final Bundle savedInstanceState) {
final View v = inflater.inflate(R.layout.list, container, false);
mSwipeRefreshWidget = (SwipeRefreshLayout) v.findViewById(R.id.swipe_refresh_widget);
mSwipeRefreshWidget.setOnRefreshListener(this);
mSwipeRefreshWidget.setColorScheme(R.color.refresh1, R.color.refresh2, R.color.refresh3,
R.color.refresh4);
// snip
}
Github 上的完整源代码: https://github.com/meisteg/PickTheWinner/blob/d764c69af0c72a2d1173c6fb4328bd85088d8b59/app/src/com/meiste/greg/ptw/tab/Schedule.java
有人对如何解决抖动有建议吗?无论我需要多长时间来过度滚动所需的距离,过度滚动都应该是平滑的。谢谢!
【问题讨论】:
标签: java android android-support-library swiperefreshlayout