Vahid
Vahid

Reputation: 1758

recycelerview item onclick steal appbarlayout scrolling

I have a recyclerview with multi view type , some of view have items with onclick . when I scroll in recyclerview if touch outside clickable items appbarlayout hide/show ,But if i put my finger on clickable item for scroll the recyclerview it will steal focus and appbarlayout do not hide/show

Activity

<android.support.design.widget.AppBarLayout
    android:id="@+id/app_bar"
    android:layout_width="match_parent"
    android:layout_height="56dp"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <ViewSwitcher
        android:id="@+id/vs"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        app:layout_scrollFlags="scroll|enterAlways|snap">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways|snap"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light">

            <TextView
                android:id="@+id/toolbar_title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="right|center_horizontal"
                android:ellipsize="end"
                android:maxLines="1"
                android:paddingRight="0dp"
                android:textColor="@color/md_white_1000"
                android:textSize="16dp" />
        </android.support.v7.widget.Toolbar>

        <RelativeLayout xmlns:app="http://schemas.android.com/apk/res-auto"
            android:layout_width="match_parent"
            android:layout_height="56dp"
            android:background="@color/md_white_1000"
            android:elevation="2dp"
            android:fitsSystemWindows="true">

        </RelativeLayout>

    </ViewSwitcher>


</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_activity_main" />

Fragment with recyclerview

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clipToPadding="false"
    app:layout_collapseMode="parallax"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    android:orientation="vertical">

    <LinearLayout
        android:id="@+id/ll_progress"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ProgressBar
            style="?android:attr/progressBarStyle"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:layout_gravity="center_vertical|center_horizontal"
            android:layout_margin="25dp" />
    </LinearLayout>

    <android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/rv_dashboard"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layoutDirection="rtl"/>
</LinearLayout>

Upvotes: 0

Views: 192

Answers (1)

Vahid
Vahid

Reputation: 1758

If add .setNestedScrollingEnabled(false); into inner recyclerview it will be done !

Upvotes: 0

Related Questions