I have the following layout:
<?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>
I basically have three parts of this layout. First a layout containing just a textview to show if no data is set. It is getting invisible when there is data.
The second part is my recyclerview which is only showing up, when some data is set.
The last part are two buttons. My problem with this layout? The scrolling is really slow. I dont mean lagging or something like that. I just can scroll a small part. It is not like my other scrollviews where i am able to fling the view so that it scrolls automatically. I have no idea what is different with this layout and why the scrollview works different here then in my other layouts. Is there something blocking the scrollview fling or something like that?
A view group that allows the view hierarchy placed within it to be scrolled. Scroll view may have only one direct child placed within it. To add multiple views within the scroll view, make the direct child you add a view group, for example LinearLayout , and place additional views within that LinearLayout.
Your Recyclerview
is colliding with ScrollView
that's why scroll is not smooth.
Try disabling scrolling of recyclerview.
RecyclerView recyclerView = (RecyclerView)findViewById(R.id.datatransfer_measure_list_row_parent);
recyclerView.setNestedScrollingEnabled(false)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With