codepath / android_guides

Extensive Open-Source Guides for Android Developers
guides.codepath.com
MIT License
28.29k stars 6.35k forks source link

Scrolling issue #317

Open SatvirGsBitlabs opened 6 years ago

SatvirGsBitlabs commented 6 years ago

Hi I am developing app in which I am having a view similar to Instagram (https://user-images.githubusercontent.com/35765225/35329279-4444b0ee-00f7-11e8-8408-95c6d0bfb04d.jpeg) I want a scrolling effect similar to instagram. When it is scrolled up its working perfectly fine,the above view is auto-collapsing. But when i am clicking on any item in recyclerview I want the above auto collapsed view should expand that i achieved from appbar.setExpanded(true) But when it is expanding it is scrolling the recyclerview also.I don't want the recyclerview to scroll with it.The clicked item should be on top like instagram. Please Help.

aloksr commented 6 years ago

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/maincontent" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true">

<android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:fitsSystemWindows="true" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

<android.support.design.widget.CollapsingToolbarLayout
    android:id="@+id/collapse_toolbar"
    android:layout_width="match_parent"
    android:layout_height="256dp"
    app:expandedTitleMarginBottom="30dp"
    android:fitsSystemWindows="true"
    app:contentScrim="@color/color_primary"
    app:layout_scrollFlags="scroll|exitUntilCollapsed">

    <ImageView
        android:id="@+id/backdrop"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/default_banner"
        android:fitsSystemWindows="true"
        android:scaleType="centerCrop"
        app:layout_collapseMode="parallax" />

    <View
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/bg_course_aparallax"
        android:fitsSystemWindows="true"
        android:scaleType="centerCrop"
        app:layout_collapseMode="parallax" />

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:gravity="top"
        android:minHeight="?attr/actionBarSize"
        app:layout_collapseMode="pin"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        app:titleMarginTop="13dp" />

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

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

<android.support.design.widget.TabLayout android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="48dp" app:layout_behavior="@string/appbar_scrolling_view_behavior" app:tabMode="scrollable" android:elevation="@dimen/dimen_5" app:tabTextColor="@color/course_tab_inactive" app:tabSelectedTextColor="@color/course_tab_color" android:background="@color/button_text_color" app:tabIndicatorColor="@color/course_tab_color" />

<android.support.v4.view.ViewPager android:id="@+id/viewpager" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="48dp" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> </android.support.design.widget.CoordinatorLayout>

We use Gridview in Side Frame Layout it will be ferfect.