I'm using ScrollView for scrolling in my page. But for some reason it is laggy and slower at the top of the page but when I scroll down it is smoother and faster. I don't understand why it behaves this way. You can see here is a video of what is happening:
https://drive.google.com/file/d/1y9Q-JNFBGxHdKUkE_KRWCxfYqxRln7Vn/view?usp=sharing
It was all working just fine, I added four more CardsView and then this issue happened. Here is a snippet of the code:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/top"
android:background="#F4F2F2"
tools:context=".ui.home.HomeFragment">
<GridLayout
android:columnCount="2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp">
<FrameLayout
android:layout_width="60dp"
android:layout_height="wrap_content"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_margin="20dp"
>
<ImageView
android:id="@+id/dog"
android:layout_width="101dp"
android:layout_height="61dp"
android:layout_gravity="bottom|center"
android:elevation="5dp"
android:src="@drawable/dog" />
<androidx.cardview.widget.CardView
android:id="@+id/d1"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_marginTop="15dp"
android:layout_marginBottom="20dp"
app:cardCornerRadius="20dp"
app:cardElevation="2dp"
>
<RelativeLayout
android:id="@+id/image_container1"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/cave"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:adjustViewBounds="true"
android:maxHeight="400dp"
android:scaleType="fitXY"
android:src="@drawable/cave"/>
<TextView
android:id="@+id/myImageViewText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="@id/cave"
android:layout_alignLeft="@id/cave"
android:layout_alignTop="@id/cave"
android:layout_alignEnd="@id/cave"
android:layout_alignRight="@id/cave"
android:layout_alignBottom="@id/cave"
android:layout_marginStart="1dp"
android:layout_marginLeft="1dp"
android:layout_marginTop="1dp"
android:layout_marginEnd="1dp"
android:layout_marginRight="1dp"
android:layout_marginBottom="1dp"
android:fontFamily="@font/arghavan"
android:textSize="20dp"
android:gravity="center"
android:text="@string/s1"
android:textColor="#000"
android:textStyle="bold" />
</RelativeLayout>
</androidx.cardview.widget.CardView>
</FrameLayout>
<FrameLayout
android:layout_width="60dp"
android:layout_height="wrap_content"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_margin="20dp"
>
<ImageView
android:id="@+id/play"
android:layout_width="100dp"
android:layout_height="80dp"
android:elevation="10dp"
android:layout_gravity="top|center"
android:src="@drawable/yonuswheal" />
<androidx.cardview.widget.CardView
android:id="@+id/d2"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_marginTop="15dp"
android:layout_marginBottom="20dp"
app:cardCornerRadius="20dp"
app:cardElevation="2dp">
<RelativeLayout
android:id="@+id/image_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/sea"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:adjustViewBounds="true"
android:maxHeight="400dp"
android:scaleType="fitXY"
android:src="@drawable/sea" />
<TextView
android:id="@+id/myImageViewText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/sea"
android:layout_alignTop="@id/sea"
android:layout_alignRight="@id/sea"
android:layout_alignBottom="@id/sea"
android:layout_marginStart="1dp"
android:layout_marginTop="1dp"
android:layout_marginEnd="1dp"
android:layout_marginBottom="1dp"
android:fontFamily="@font/arghavan"
android:textSize="20dp"
android:gravity="center"
android:text="@string/s2"
android:textColor="#000"
android:textStyle="bold" />
</RelativeLayout>
</androidx.cardview.widget.CardView>
</FrameLayout>
</ScrollView>