I don't understand why my CollapsingToolbar layout is collapsed when my view is created by default.
I think this the NestedScrollView the responsible but i don't no why.
This make me crazy.
My activity layout :
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar"
android:layout_width="match_parent"
android:layout_height="#dimen/app_bar_height"
android:fitsSystemWindows="true"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v4.view.ViewPager
android:id="#+id/pager_images"
android:layout_width="match_parent"
android:layout_height="match_parent"
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"
app:layout_collapseMode="pin"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_product" />
</android.support.design.widget.CoordinatorLayout>
And my content_layout with nested scrollview :
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="4dp">
<include layout="#layout/layout_progress" />
<TextView
android:id="#+id/tv_reference"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="2dp"
android:layout_marginTop="8dp"
android:ellipsize="end"
android:maxLines="1"
android:text=""
android:textColor="#color/MyApp_gray"
android:textSize="10sp"
android:textStyle="bold" />
<TextView
android:id="#+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:ellipsize="end"
android:fontFamily="sans-serif-light"
android:maxLines="2"
android:text=""
android:textColor="#color/cardview_dark_background"
android:textSize="16sp" />
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/card_view_choix"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginTop="4dp"
android:background="#android:color/white"
card_view:cardCornerRadius="2dp"
card_view:cardElevation="1dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<TextView
android:id="#+id/tv_quantity_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="8dp"
android:ellipsize="end"
android:maxLines="2"
android:text="#string/product_quantity"
android:textColor="#color/cardview_dark_background"
android:textSize="12sp" />
<com.MyApp.utils.HorizontalNumberPicker
android:id="#+id/horizontal_qty_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:background="#color/MyApp_gray" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="#+id/tv_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text=""
android:textColor="#color/cardview_dark_background"
android:textSize="18sp"
android:textStyle="" />
<TextView
android:id="#+id/tv_price_unit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text=" / Unité"
android:textColor="#color/cardview_dark_background"
android:textSize="16sp" />
</LinearLayout>
<TextView
android:id="#+id/tv_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="10dp"
android:drawableLeft="#drawable/ic_hourglass_red_18dp"
android:drawablePadding="4dp"
android:gravity="center"
android:maxLines="2"
android:text=""
android:textColor="#color/MyApp_gray"
android:textSize="12sp"
android:visibility="gone" />
</LinearLayout>
</android.support.v7.widget.CardView>
<Button
android:id="#+id/btn_book"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="30dp"
android:layout_marginTop="10dp"
android:background="#drawable/btn_primary"
android:drawableLeft="#drawable/ic_add_shopping_cart_white_24dp"
android:drawablePadding="10dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:text="#string/store_action_book"
android:textColor="#android:color/white"
android:textStyle="bold" />
<TextView
android:id="#+id/tv_desc_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="2dp"
android:layout_marginTop="20dp"
android:ellipsize="end"
android:maxLines="1"
android:text="#string/product_description"
android:textColor="#color/cardview_dark_background"
android:textSize="14sp"
android:textStyle="bold" />
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginTop="4dp"
android:background="#android:color/white"
card_view:cardCornerRadius="2dp"
card_view:cardElevation="1dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<at.blogc.android.views.ExpandableTextView
android:id="#+id/tv_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginTop="10dp"
android:ellipsize="end"
android:maxLines="5"
android:text=""
android:textColor="#color/MyApp_gray"
android:textIsSelectable="true"
android:textSize="12sp"
app:animation_duration="1000" />
<Button
android:id="#+id/btn_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#android:color/transparent"
android:text="#string/action_expand"
android:textColor="#color/MyApp_red" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
Rendering :
More strange it still working when i use the NestedScrollView to top. It seems like the NestedScrollView scroll to bottom automatically.
Solved with this thread :
nestedscrollview-scroll-down-itself-when-content-is-fills
android:descendantFocusability="blocksDescendants" to the LinearLayout inside NestedScrollView
Worked for me.
Related
I have a situation where linearlayout doesn't stay fixed at the bottom of the co-ordinatorlayout but moves with respect to the scrollview contents above.
I have tried all solutions on StackOverflow but still no luck (ex:Keep LinearLayout at the bottom of screen and even tried relativelayout but no luck: Make a RelativeLayout at the bottom of a Scrollview ). I am not sure what could be causing this, for the linear/relativelayout to move with respect to the scrollview, but if anyone else can figure out what I am doing wrong or missing, that'll be a great help!
Thanks in advance! Here's my XML code below: (open to sharing any other relevant java code if that helps )
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:background="#color/white"
android:clickable="false"
android:fitsSystemWindows="true"
android:fillViewport="true"
android:id="#+id/cl_root_view"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/main_register_container"
android:layout_marginBottom="60dp"
android:background="#color/white"
android:orientation="vertical">
<LinearLayout
android:id="#+id/activity_register_guest"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:elevation="0dp">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
app:subtitleTextColor="#color/white"
app:titleTextAppearance="#style/Toolbar.TitleText"
app:titleTextColor="#color/white">
<!--<TextView
android:id="#+id/nav_back_btn"
style="#style/Body1RegLeftBlack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/activity_horizontal_margin"
android:layout_marginTop="20dp"
android:background="#drawable/ic_backarrow"
android:gravity="center_horizontal" />-->
<TextView
android:id="#+id/register_guest_main_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="18dp"
android:layout_marginTop="15dp"
android:layout_gravity="center"
android:letterSpacing="0.01"
android:textAllCaps="true"
android:text="#string/register_guest"
android:textAppearance="#style/TextAppearance.Text.Roboto.Medium"
android:textColor="#de000000"
android:textSize="17sp"
android:textStyle="normal"
/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:background="#color/white"
android:fitsSystemWindows="true"
android:layout_marginBottom="65dp">
<RelativeLayout
android:id="#+id/register_visitor_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:clickable="false"
android:fillViewport="true">
<LinearLayout
android:id="#+id/main_register_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">
<TextView
android:id="#+id/my_location"
style="#style/Headline2LeftBlack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/activity_horizontal_margin"
android:textAppearance="#style/TextAppearance.Text.Chronicle"
android:textSize="28sp"
tools:text="#string/five_thirty_fifth_ave" />
<TextView
style="#style/Body1RegRightRed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/my_location"
android:layout_alignParentEnd="true"
android:layout_marginEnd="#dimen/activity_horizontal_margin"
android:layout_toEndOf="#+id/my_location"
android:text="#string/location_change"
android:textAppearance="#style/TextAppearance.Text.Roboto.Regular"
android:visibility="gone" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="28dp"
android:layout_marginTop="24dp"
android:gravity="center_vertical"
android:layout_marginBottom="8dp"
android:weightSum="2">
<TextView
android:id="#+id/select_date_and_time"
android:layout_width="wrap_content"
android:textSize="17sp"
android:lineSpacingExtra="6sp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:textColor="#color/black"
android:text="#string/select_date_and_time"
android:textAppearance="#style/TextAppearance.Text.Roboto.Medium" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="#color/registerUserSeparatorColor" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:gravity="center_vertical"
android:weightSum="2">
<TextView
android:id="#+id/register_guest_start_date"
style="#style/Body1RegLeftBlack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_weight="1"
android:text="#string/register_guest_start_date"
android:textAppearance="#style/TextAppearance.Text.Roboto.Regular" />
<TextView
android:id="#+id/register_guest_start_time"
style="#style/Body1RegRightBlack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_weight="1"
android:text="#string/register_guest_start_time"
android:textAppearance="#style/TextAppearance.Text.Roboto.Regular" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="#color/registerUserSeparatorColor" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:gravity="center_vertical"
android:weightSum="2">
<TextView
android:id="#+id/register_guest_end_date"
style="#style/Body1RegLeftBlack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_weight="1"
android:text="#string/register_guest_end_date"
android:textAppearance="#style/TextAppearance.Text.Roboto.Regular"
android:visibility="invisible" />
<TextView
android:id="#+id/register_guest_end_time"
style="#style/Body1RegRightBlack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_weight="1"
android:text="#string/register_guest_end_time"
android:textAppearance="#style/TextAppearance.Text.Roboto.Regular" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="#color/registerUserSeparatorColor" />
<TextView
android:id="#+id/build_your_guest_list"
android:layout_width="wrap_content"
android:textSize="17sp"
android:layout_marginTop="42dp"
android:lineSpacingExtra="6sp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:textColor="#color/black"
android:text="#string/build_your_guest_list"
android:paddingBottom="8dp"
android:textAppearance="#style/TextAppearance.Text.Roboto.Medium" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="#color/registerUserSeparatorColor" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="44dp"
android:id="#+id/add_guest"
android:layout_marginTop="3dp"
android:layout_marginBottom="8dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="44dp"
android:lineHeight="22sp"
android:drawablePadding="10dp"
android:drawableStart="#drawable/ic_add_24px"
android:drawableTint="#color/bluish"
android:layout_marginStart="17dp"
android:lineSpacingExtra="6sp"
android:textColor="#color/bluish"
android:gravity="center_vertical"
android:textAppearance="#style/TextAppearance.Text.Roboto.Medium"
android:text="#string/add_a_new_guest"
android:textSize="17sp" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="#color/registerUserSeparatorColor"
/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="44dp"
android:id="#+id/search_guest"
android:layout_marginTop="3dp"
android:visibility="gone"
android:layout_marginBottom="8dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="44dp"
android:lineHeight="22sp"
android:drawablePadding="10dp"
android:drawableStart="#drawable/ic_search_24px"
android:drawableTint="#color/bluish"
android:layout_marginStart="17dp"
android:lineSpacingExtra="6sp"
android:textColor="#color/bluish"
android:gravity="center_vertical"
android:textAppearance="#style/TextAppearance.Text.Roboto.Medium"
android:text="#string/search_past_guests"
android:textSize="17sp" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:visibility="gone"
android:id="#+id/search_guest_line"
android:background="#color/registerUserSeparatorColor"
/>
<android.support.v7.widget.RecyclerView
android:id="#+id/guest_item_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="#null"
android:overScrollMode="never"
tools:listitem="#layout/item_guest" />
<TextView
android:id="#+id/arrival_notifications"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="58dp"
android:letterSpacing="0.01"
android:lineSpacingExtra="4sp"
android:text="#string/arrival_notifications"
android:textAppearance="#style/TextAppearance.Text.Roboto.Medium"
android:textColor="#color/black"
android:textSize="20sp"
android:textStyle="normal"
android:visibility="invisible" />
<RelativeLayout
android:id="#+id/text_message_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:visibility="gone">
<TextView
android:id="#+id/text_message"
style="#style/Body1RegLeftBlack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="11dp"
android:text="#string/text_message"
android:textAppearance="#style/TextAppearance.Text.Roboto.Regular" />
<TextView
android:id="#+id/tap_phone_number_text"
style="#style/Body2RegLeftGrey"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/text_message"
android:layout_marginTop="2dp"
android:text="#string/tap_to_add_a_phone_number"
android:textAppearance="#style/TextAppearance.Text.Roboto.Regular" />
<android.support.v7.widget.SwitchCompat
android:id="#+id/text_message_switch"
style="#style/Color1SwitchStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="16dp" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="16dp"
android:layout_marginTop="11dp"
android:background="#color/settingsSeparatorLineColor"
android:visibility="gone" />
</LinearLayout>
<!-- <TextView
android:id="#+id/submit_users_btn"
style="#style/LoginButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|bottom"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:paddingBottom="30dp"
android:letterSpacing="0.07"
android:lineSpacingExtra="0sp"
android:text="#string/submit_visitor_list"
android:textAppearance="#style/TextAppearance.Text.Roboto.Medium"
android:textSize="16sp"
android:textStyle="normal" /> -->
</RelativeLayout>
</ScrollView>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_gravity="center|bottom"
android:background="#color/transparent"
android:layout_marginBottom="75dp"
android:orientation="vertical"
android:id="#+id/fixedSubmitButtonlayout">
<TextView
android:id="#+id/submit_users_btn"
android:textColor="#757575"
android:textAlignment="center"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#drawable/textview_border"
android:letterSpacing="0.07"
android:gravity="center"
android:lineSpacingExtra="0sp"
android:text="#string/register_guest_caps"
android:textAppearance="#style/TextAppearance.Text.RidleyGrotesk.Regular"
android:textSize="16sp"
android:textStyle="normal" />
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
From the code above, the layout I am trying to fix at the bottom has id is: android:id="#+id/fixedSubmitButtonlayout".
I want it to stay intact/fixed at the bottom of the screen irrespective of the scrollview above it which is supposed to scroll behind it ( it does as of now, just the button position changes as the scroll view content overflows screen size). any ideas on how to fix this?
Just need to do this steps:
add a RelativeLayout as a Parent of CoordinatorLayout and
take out the last LinearLayout from CoordinatorLayout and
add it to RelativeLayout with android:layout_alignParentBottom="true".
note that you need to add android:layout_marginBottom="40dp" to your CoordinatorLayout
You can try this (tested and it works fine):
<RelativeLayout 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"
>
<your CoordinatorLayout>
</your CoordinatorLayout>
<LinearLayout
android:id="#+id/fixedSubmitButtonlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_gravity="center|bottom"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="#color/transparent"
android:orientation="vertical"
>
<TextView
android:id="#+id/submit_users_btn"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#drawable/textview_border"
android:gravity="center"
android:letterSpacing="0.07"
android:lineSpacingExtra="0sp"
android:text="#string/register_guest_caps"
android:textAlignment="center"
android:textAppearance="#style/TextAppearance.Text.RidleyGrotesk.Regular"
android:textColor="#757575"
android:textSize="16sp"
android:textStyle="normal"
/>
</LinearLayout>
</RelativeLayout>
It will work better in Relative layout
android:layout_alignParentBottom="true"
In your CoordinatorLayout, your View must be a direct child and not a child of another View inside the CoordinatorLayout. Then you can add this line of code to it:
android:layout_gravity="bottom"
The structure can be like this:
- CoordinatorLayout //(Parent View)
- - AppBarLayout //(Child View - Toolbar)
- - NestedScrollView //(Child View - Scrollable Content)
- - LinearLayout //(Child View - Bottom Fixed Content)
Here's a Sample code how it's supposed to be:
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/black_overlay"
android:theme="#style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="#style/Toolbar.Light"
app:contentInsetStartWithNavigation="0dp"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light">
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!--Your Scrollable Content Goes Here-->
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical">
<!--Your Fixed Bottom Content Goes Here-->
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
I have a problem I want the orange cardView on the top to be like this:
and when the user Scorll I have to make this orange card scroll as well
but I used coordinate layout with anchor for the card
I've to make it invisible when the user scrolls away a little bit but I have this:
my question is how to make this orange cardview to stay and scroll with other layout elements?
my xml file is:
<?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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:elevation="0dp">
<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_collapseMode="pin"
app:popupTheme="#style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView
android:id="#+id/nested_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="#+id/profile_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="60dp"
android:layout_marginLeft="#dimen/app_margin"
android:layout_marginRight="#dimen/app_margin"
android:layout_marginBottom="#dimen/app_margin"
app:elevation="3dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Medium"
android:layout_marginTop="60dp"
android:layout_marginBottom="#dimen/app_margin"
android:text="Mark Davis"
android:layout_centerHorizontal="true"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="#id/username"
android:text="IT consuler"
android:layout_marginBottom="#dimen/app_margin"
android:id="#+id/textView" />
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/textView"
android:layout_marginTop="15dp"
android:layout_weight="1"
android:elevation="3dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Personal Information"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Medium" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</android.support.v7.widget.CardView>
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_margin="#dimen/app_margin"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Medium"
android:text="Personal Inforamtion"
android:elevation="3dp"
android:textStyle="bold"
android:layout_margin="#dimen/app_margin"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="User Name"
android:textStyle="bold"
android:textSize="16sp"
android:textColor="#color/colorAccent"
android:layout_marginBottom="#dimen/app_margin"
android:layout_marginLeft="#dimen/app_margin"
android:textAppearance="#style/TextAppearance.AppCompat.Small"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="User Name"
android:layout_marginLeft="32dp"
android:layout_marginRight="#dimen/app_margin"
android:layout_marginBottom="#dimen/app_margin"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Email"
android:textStyle="bold"
android:textSize="16sp"
android:textColor="#color/colorAccent"
android:layout_marginBottom="#dimen/app_margin"
android:layout_marginLeft="#dimen/app_margin"
android:textAppearance="#style/TextAppearance.AppCompat.Small"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email"
android:layout_marginLeft="32dp"
android:layout_marginRight="#dimen/app_margin"
android:layout_marginBottom="#dimen/app_margin"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Display name"
android:textStyle="bold"
android:textSize="16sp"
android:textColor="#color/colorAccent"
android:layout_marginBottom="#dimen/app_margin"
android:layout_marginLeft="#dimen/app_margin"
android:textAppearance="#style/TextAppearance.AppCompat.Small"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Display name"
android:layout_marginLeft="32dp"
android:layout_marginRight="#dimen/app_margin"
android:layout_marginBottom="#dimen/app_margin"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Password"
android:textStyle="bold"
android:textSize="16sp"
android:textColor="#color/colorAccent"
android:layout_marginBottom="#dimen/app_margin"
android:layout_marginLeft="#dimen/app_margin"
android:textAppearance="#style/TextAppearance.AppCompat.Small"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:layout_marginLeft="32dp"
android:layout_marginRight="#dimen/app_margin"
android:layout_marginBottom="#dimen/app_margin"/>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.v7.widget.CardView
android:id="#+id/profile_pic"
android:layout_margin="#dimen/app_margin"
android:layout_width="100dp"
android:layout_height="100dp"
app:layout_anchor="#id/profile_card"
app:layout_anchorGravity="center|top"
app:cardCornerRadius="50dp"
app:cardBackgroundColor="#color/colorAccent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/ic_profile"/>
</android.support.v7.widget.CardView>
<android.support.design.widget.FloatingActionButton
android:id="#+id/buttonLove"
android:layout_width ="wrap_content"
android:layout_height="wrap_content"
android:src = "#drawable/ic_edit"
app:borderWidth="0dp"
android:elevation="5dp"
app:pressedTranslationZ="12dp"
app:rippleColor="#color/button_white"
android:onClick="onClick"
android:background="#color/colorAccent"
android:layout_margin="#dimen/app_margin"
android:layout_gravity="bottom|end"
app:fabSize="normal"
/>
</android.support.design.widget.CoordinatorLayout>
like shown in the link
https://dribbble.com/shots/2339508-Dark-Profile-Screen
when I try to put view pager down the activity it does not hold the fragment.
Only the tablayout appears. I have tried keeping viewpager outside the nestedScrollableView and keeping the content of fragments inside nested scrollableview still fragments are not scrolling inside the activity.Thanks in advance.
`<android.support.v4.widget.NestedScrollView
android:id="#+id/myScrollingContent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<RelativeLayout android:layout_height="match_parent"
android:layout_width="match_parent">
<com.github.florent37.diagonallayout.DiagonalLayout
android:layout_width="match_parent"
android:layout_height="350dp"
android:elevation="0dp"
app:diagonal_angle="35"
app:diagonal_position="bottom"
app:diagonal_direction="left">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/coverImage"
android:scaleType="centerCrop"
android:src="#drawable/kygo" />
</com.github.florent37.diagonallayout.DiagonalLayout>
<com.mikhaellopez.circularimageview.CircularImageView
android:id="#+id/thumbnailview"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginTop="180dp"
android:layout_centerHorizontal="true"
android:src="#drawable/kygo"
android:elevation="5dp"
app:civ_border_color="#ffffff"
app:civ_border_width="5dp"
/>
<LinearLayout
android:layout_height="60dp"
android:layout_width="match_parent"
android:layout_alignLeft="#+id/thumbnailview"
android:layout_marginLeft="90dp"
android:layout_marginRight="10dp"
android:layout_marginTop="190dp"
android:orientation="vertical">
<TextView android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp"
android:fontFamily="sans-serif-condensed"
android:layout_marginTop="20dp"
android:layout_marginBottom="5dp"
android:textStyle="bold"
android:text="ALAN WALKER"/>
</LinearLayout>
<LinearLayout
android:layout_height="70dp"
android:layout_width="match_parent"
android:layout_alignTop="#+id/thumbnailview"
android:layout_alignLeft="#+id/thumbnailview"
android:layout_marginRight="10dp"
android:weightSum="9"
android:layout_marginTop="80dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_below="#+id/diagonalLayout"
android:layout_weight="3"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="45"
android:textStyle="bold"
android:textColor="#3E3E3E"
android:fontFamily="sans-serif-condensed"
android:layout_marginLeft="10dp"
android:textSize="20sp"
android:id="#+id/textView"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Videos"
android:textColor="#3E3E3E"
android:fontFamily="sans-serif-condensed"
android:layout_marginLeft="10dp"
android:textSize="14sp"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_marginTop="20dp"
android:layout_height="wrap_content"
android:layout_below="#+id/diagonalLayout"
android:layout_weight="3"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="12"
android:textStyle="bold"
android:textColor="#3E3E3E"
android:fontFamily="sans-serif-condensed"
android:layout_marginLeft="10dp"
android:textSize="20sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Views"
android:textColor="#3E3E3E"
android:fontFamily="sans-serif-condensed"
android:layout_marginLeft="10dp"
android:textSize="14sp"/>
</LinearLayout>
</LinearLayout>
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_below="#+id/buttons"
android:layout_height="wrap_content"
app:tabMode="fixed"
app:tabGravity="fill"/>
<android.support.v4.view.ViewPager
android:id="#+id/viewpager"
android:layout_below="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>`
CollapsingToolbarLayout also collapse Toolbar when using with RecyclerView when scrolling up
I don't want to make Toolbar(ActionBar) disappear when scrolling screen up or while collapsing within AppBarLayout.
I am using CoordinatorLayout.
Following is my layout file
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
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:id="#+id/coordinator"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="#dimen/header_pic_height"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways"
android:fitsSystemWindows="true"
app:contentScrim="#color/PrimaryColor"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_collapseMode="parallax">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="#style/AppTheme"
android:title=" "
app:layout_collapseMode="pin" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
app:layout_collapseMode="parallax"
android:background="#color/PrimaryColor"
android:padding="5dp">
<FrameLayout
android:layout_width="55dp"
android:layout_marginLeft="8dp"
android:layout_height="match_parent"
android:layout_marginRight="16dp">
<ImageView
android:id="#+id/imageView"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="4dp"
android:layout_marginTop="5dp"
/>
<ImageView
android:id="#+id/check_icon"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginBottom="20dp"
android:src="#drawable/check_sm"
android:layout_gravity="center_vertical"
android:visibility="gone" />
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_collapseMode="parallax" >
<TextView
android:id="#+id/projectName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/MainFragmentTicketItemAccount"
android:ellipsize="end"
android:singleLine="true"
android:text="Project Name"
android:layout_marginLeft="6dp"
android:textColor="#android:color/white"
android:textSize="#dimen/list_text_size"/>
<TextView
android:id="#+id/labelProjectNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:ellipsize="end"
android:gravity="right"
android:singleLine="true"
android:text="#string/lbl_project_no"
android:textSize="14sp"
android:textColor="#color/label_color" />
<TextView
android:id="#+id/projectNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:maxLines="2"
android:layout_marginLeft="6dp"
android:text="657894512"
android:textStyle="bold"
android:textColor="#color/text_color"
android:textSize="12sp" />
<TextView
android:id="#+id/labelAccountName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="15dp"
android:ellipsize="end"
android:gravity="right"
android:singleLine="true"
android:text="#string/lbl_account_name"
android:textSize="14sp"
android:textColor="#color/label_color" />
<TextView
android:id="#+id/accountName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:maxLines="2"
android:layout_marginLeft="6dp"
android:text="Aqui del carlos"
android:textStyle="bold"
android:textColor="#color/text_color"
android:textSize="12sp" />
<TextView
android:id="#+id/labelstartDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="15dp"
android:ellipsize="end"
android:gravity="right"
android:singleLine="true"
android:text="#string/start_date"
android:textSize="14sp"
android:textColor="#color/label_color" />
<TextView
android:id="#+id/startDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:maxLines="2"
android:layout_marginLeft="6dp"
android:text="25-06-2016"
android:textStyle="bold"
android:textColor="#color/text_color"
android:textSize="12sp" />
<TextView
android:id="#+id/labelEndDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="15dp"
android:ellipsize="end"
android:gravity="right"
android:singleLine="true"
android:text="#string/acc5"
android:textSize="14sp"
android:textColor="#color/label_color" />
<TextView
android:id="#+id/endDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:maxLines="2"
android:layout_marginLeft="6dp"
android:text="30-06-2016"
android:textStyle="bold"
android:textColor="#color/text_color"
android:textSize="12sp" />
<TextView
android:id="#+id/labelpadidod_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="15dp"
android:ellipsize="end"
android:gravity="right"
android:singleLine="true"
android:text="#string/lbl_padido_no"
android:textSize="14sp"
android:textColor="#color/label_color" />
<TextView
android:id="#+id/padidoNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:maxLines="2"
android:layout_marginLeft="6dp"
android:text="4581233"
android:textStyle="bold"
android:textColor="#color/text_color"
android:textSize="12sp" />
<TextView
android:id="#+id/lbl_installation_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="15dp"
android:ellipsize="end"
android:gravity="right"
android:singleLine="true"
android:text="#string/lbl_installation_no"
android:textSize="14sp"
android:textColor="#color/label_color" />
<TextView
android:id="#+id/installationNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:maxLines="2"
android:layout_marginLeft="6dp"
android:text="4581233"
android:textStyle="bold"
android:textColor="#color/text_color"
android:textSize="12sp" />
<TextView
android:id="#+id/lbl_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="15dp"
android:ellipsize="end"
android:gravity="right"
android:singleLine="true"
android:text="#string/status"
android:textSize="14sp"
android:textColor="#color/label_color" />
<TextView
android:id="#+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:maxLines="2"
android:layout_marginLeft="6dp"
android:text="Activo"
android:textStyle="bold"
android:textColor="#color/text_color"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
<ImageView
android:id="#+id/imageView123"
android:layout_width="match_parent"
android:layout_height="30dp"
android:src="#drawable/arrow_up_circle"/>
</LinearLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/simpleRecyclerView"
android:layout_height="match_parent"
android:layout_width="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:id="#+id/MainFragmentEmptyLinearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="gone"
android:gravity="center">
<ImageView
android:layout_height="194dp"
android:layout_width="253dp"
android:src="#drawable/ic_main_no_data"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/no_data1"
android:textSize="25sp"
android:textStyle="bold"
android:textColor="#color/info_no_data_color"
android:layout_marginTop="10dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/no_data2"
android:textSize="15sp"
android:textStyle="normal"
android:textColor="#color/info_no_data_color"
android:layout_marginTop="5dp"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
while scrolling appBar it should be fixed when reached to toolbar height, so i need toolbar fixed at its position.
thanks.
My requirement is something different from other SO question that is toolBar not collapsing etc but in my case i don't wanted to collapse my toolBar while scrolling up and collapsing appBar,
So i came up with following solution, this will help someone with similar issue.
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:minHeight="?attr/actionBarSize"
android:fitsSystemWindows="true"
app:contentScrim="#color/PrimaryColor"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp">
following couple line of code solved my issue.
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:minHeight="?attr/actionBarSize"
I have a collapsing toolbar layout, below that a tab layout and below that the corresponding viewpager. I want to implement snapping such that when I collapse the collapsing toolbar layout more than half and leave it, it should snap and collapse completely. How do I do it? Here is my actual layout :
<?xml version="1.0" encoding="utf-8"?>
<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/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#231f20"
android:fitsSystemWindows="true">
<android.support.v4.view.ViewPager
android:id="#+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="bottom"
android:background="#231f20"
app:layout_anchor="#+id/appbar"
app:layout_anchorGravity="bottom"
app:tabGravity="fill"
app:tabMode="fixed" />
<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/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="#FAC80A"
app:expandedTitleMarginBottom="110dp"
app:expandedTitleMarginStart="200dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax">
<ImageView
android:id="#+id/imageView78"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:background="#drawable/user_profile_bg_img"
android:scaleType="fitXY"
android:src="#drawable/gradient" />
<ImageView
android:id="#+id/imageView82"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="10dp"
android:src="#drawable/user_profile_shape_profile_pic"
android:layout_centerVertical="true"
android:layout_marginLeft="30dp" />
<ImageView
android:id="#+id/imageView80"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="center_vertical"
android:elevation="10dp"
android:layout_marginRight="60dp"
android:layout_marginTop="35dp" />
<ImageView
android:id="#+id/imageView81"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:elevation="10dp"
android:layout_gravity="center_vertical"
android:layout_marginRight="20dp"
android:layout_marginTop="35dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginLeft="30dp"
android:layout_marginTop="300dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="vertical"
android:paddingRight="10dp"
android:elevation="10dp"
android:id="#+id/fans">
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:textSize="16sp" />
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0.8"
android:text="Fans"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF" />
</LinearLayout>
<ImageView
android:id="#+id/imageView179"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="10dp"
android:src="#drawable/user_profile_thin_line_separator_profile_metrics" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="vertical"
android:paddingRight="10dp"
android:elevation="10dp"
android:id="#+id/comments">
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:textSize="16sp" />
<TextView
android:id="#+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0.8"
android:text="Comments"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF" />
</LinearLayout>
<ImageView
android:id="#+id/imageView180"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="10dp"
android:src="#drawable/user_profile_thin_line_separator_profile_metrics" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="vertical"
android:paddingRight="10dp"
android:elevation="10dp"
android:id="#+id/bookmarks">
<TextView
android:id="#+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:textSize="16sp" />
<TextView
android:id="#+id/textView111"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0.8"
android:text="Bookmarks"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF" />
</LinearLayout>
<ImageView
android:id="#+id/imageView181"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="10dp"
android:src="#drawable/user_profile_thin_line_separator_profile_metrics" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="vertical"
android:elevation="10dp"
android:id="#+id/galleries">
<TextView
android:id="#+id/textView112"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:textSize="16sp" />
<TextView
android:id="#+id/textView113"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0.8"
android:text="Galleries"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="#+id/textView114"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="200dp"
android:layout_marginTop="200dp"
android:textColor="#FFFFFF" />
</RelativeLayout>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:elevation="4dp"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
it latest version of the design library, compile 'com.android.support:design:23.1.0', the snap has been added
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
should do it