I am have a layout in which a scrollview holds several nested views and 2 recyclerviews. The imageview at the bottom has a clicklistener which lets the user see another picture onClick.
Problem is that when I click on the imageview (@+id/imgRewards) the 1st time, the screen always jumps to the top of the above RecyclerView (android:id="@+id/monster_view"). I already tried to use "android:focusableInTouchMode="true" in the scrollviews parent Linearlayout but that does not solve the problem.
Can somebody help me please?
Here is my layout:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/mainLinDetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:orientation="vertical">
<ProgressBar
android:id="@+id/progressTitle"
android:layout_width="match_parent"
android:layout_height="100dp"
android:visibility="visible" />
<ImageView
android:id="@+id/imgTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
<androidx.core.widget.NestedScrollView
android:id="@+id/detailsScroll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:scrollbars="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="true"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical">
<TextView
android:id="@+id/txtBasicInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:textAlignment="center"
android:textColor="@color/newtxt"
android:textSize="20sp"
android:textStyle="bold" />
<androidx.gridlayout.widget.GridLayout
android:layout_width="match_parent"
android:layout_height="500dp"
android:layout_margin="2dp"
app:columnCount="4"
app:rowCount="4">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_margin="2dp"
app:cardElevation="1dp"
app:cardUseCompatPadding="true"
app:layout_columnSpan="3"
app:layout_columnWeight="1"
app:layout_rowWeight="1"
android:background="@color/card_default">
<TextView
android:id="@+id/txtDObjectiveInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="top|center_horizontal"
android:textColor="@color/colorWhite"
android:textSize="14sp" />
</RelativeLayout>
</androidx.gridlayout.widget.GridLayout>
<TextView
android:id="@+id/txtDWeaknessTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="Monster Weakness"
android:textAlignment="center"
android:textColor="@color/newtxt"
android:textSize="20sp"
android:textStyle="bold" />
<androidx.gridlayout.widget.GridLayout
android:id="@+id/gridWeakness"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="2dp"
app:columnCount="6">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_margin="2dp"
app:cardElevation="1dp"
app:cardUseCompatPadding="true"
app:layout_columnWeight="1"
app:layout_rowWeight="1"
android:background="@color/card_default">
<ImageView
android:id="@+id/imgIDragon"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_centerInParent="true"
android:scaleType="fitCenter"
app:srcCompat="@drawable/dragon" />
</RelativeLayout>
</androidx.gridlayout.widget.GridLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/monster_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical" />
<TextView
android:id="@+id/txtRewardsTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:textAlignment="center"
android:textColor="@color/newtxt"
android:textSize="20sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:background="@color/card_default"
android:orientation="vertical">
<TextView
android:id="@+id/txtRewardsInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textAlignment="center"
android:textColor="@color/colorWhite"
android:textSize="20sp"
android:textStyle="bold" />
<ProgressBar
android:id="@+id/progressReward"
android:layout_width="match_parent"
android:layout_height="100dp"
android:visibility="visible" />
<ImageView
android:id="@+id/imgRewards"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp" />
<TextView
android:id="@+id/txtRewardsDescr"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:textAlignment="center"
android:textColor="@color/colorWhite"
android:textSize="14sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:background="@color/card_default"
android:orientation="vertical">
<TextView
android:id="@+id/txtmainTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textColor="@color/colorWhite"
android:textSize="18sp"
android:textStyle="bold" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/titles_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:scrollbars="vertical" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>