【问题标题】:ScrollView not flinging. Scrolling slowlyScrollView 不扔。缓慢滚动
【发布时间】:2023-04-02 10:04:01
【问题描述】:

我有以下布局:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="?android:attr/actionBarSize"
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <LinearLayout
            android:id="@+id/datatransfer_measure_list_layout_no_data"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <TextView
                android:id="@+id/datatransfer_measure_list_textview_no_data"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="20dp"
                android:layout_marginEnd="40dp"
                android:layout_marginStart="40dp"
                android:layout_marginTop="20dp"
                android:gravity="center"
                android:padding="5dp"
                android:text="@string/measure_data_empty"
                android:textColor="@color/textcolorprimary"
                android:textSize="18sp" />

            <View
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_gravity="center"
                android:layout_marginBottom="20dp"
                android:layout_marginEnd="20dp"
                android:layout_marginStart="20dp"
                android:background="@android:color/darker_gray"
                android:importantForAccessibility="no" />
        </LinearLayout>

        <android.support.v7.widget.RecyclerView
            android:id="@+id/datatransfer_measure_list_row_parent"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="15dp"
            android:clipToPadding="false"
            android:importantForAccessibility="no"
            android:paddingBottom="5dp"
            android:textColor="@color/textcolorprimary" />

        <Button
            android:id="@+id/datatransfer_measure_list_button_send"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginBottom="10dp"
            android:layout_marginEnd="40dp"
            android:layout_marginStart="40dp"
            android:background="@drawable/custom_button_ok"
            android:gravity="center"
            android:padding="10dp"
            android:text="@string/common_save"
            android:textColor="@drawable/custom_button_positive_text_color"
            android:textSize="20sp" />

        <Button
            android:id="@+id/datatransfer_measure_list_button_reset"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginBottom="20dp"
            android:layout_marginEnd="40dp"
            android:layout_marginStart="40dp"
            android:background="@drawable/custom_button_cancel"
            android:gravity="center"
            android:padding="10dp"
            android:text="@string/common_cancel"
            android:textColor="@drawable/custom_button_negative_text_color"
            android:textSize="20sp" />
    </LinearLayout>
</ScrollView>

我基本上有这个布局的三个部分。首先是一个仅包含一个文本视图的布局,以显示是否没有设置数据。当有数据时它变得不可见。

第二部分是我的recyclerview,只有在设置了一些数据时才会显示。

最后一部分是两个按钮。我的这个布局有问题吗? 滚动真的很慢。我不是说落后或类似的东西。我只能滚动一小部分。它不像我的其他滚动视图,我可以让视图自动滚动。我不知道这个布局有什么不同,为什么滚动视图在这里和我的其他布局不同。是否有什么东西阻止了滚动视图或类似的东西?

【问题讨论】:

    标签: android android-scrollview


    【解决方案1】:

    您的RecyclerviewScrollView 发生冲突,这就是滚动不流畅的原因。

    尝试禁用 recyclerview 的滚动。

    RecyclerView recyclerView = (RecyclerView)findViewById(R.id.datatransfer_measure_list_row_parent);
    recyclerView.setNestedScrollingEnabled(false)
    

    【讨论】:

    • 就是这样。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-17
    • 1970-01-01
    • 2015-12-03
    相关资源
    最近更新 更多