gpt4 book ai didi

java - 如何修复 SwipeRefreshLayout 抖动?

转载 作者:太空狗 更新时间:2023-10-29 14:14:26 27 4
gpt4 key购买 nike

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

有人对如何解决抖动有建议吗?无论我需要多长时间来滚动所需的距离,滚动都应该是平滑的。谢谢!

最佳答案

这在支持库 v4 的 20.0 版本中已修复。如果您使用的是 gradle:

compile 'com.android.support:support-v4:20.0'

关于java - 如何修复 SwipeRefreshLayout 抖动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23840254/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com