有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何修复布局抖动?

SwipeRefreshLayout被添加到v19中的Android支持库中。1.0: https://developer.安卓.com/reference/安卓/support/v4/widget/SwipeRefreshLayout.html

我现在已经将它添加到我的应用程序中,它的工作方式与广告中的一样。然而,如果我慢慢地刷卡,我会注意到超卷是非常不稳定的。请看此视频了解我的意思: https://www.youtube.com/watch?v=HAuadMZYRf0

我使用不同复杂程度的多个布局来解决这个问题。上面链接的视频中显示的布局为:

<安卓.support.v4.widget.SwipeRefreshLayout
    xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
    安卓:id="@+id/swipe_refresh_widget"
    安卓:layout_width="match_parent"
    安卓:layout_height="match_parent">
    <ListView
        安卓:id="@+id/content"
        安卓:layout_width="match_parent"
        安卓:layout_height="match_parent" />
</安卓.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

有人对如何纠正这种急动有什么建议吗?过卷应该是平滑的,无论我花多长时间过卷所需的距离。谢谢


共 (1) 个答案

  1. # 1 楼答案

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

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