How to implement snapping in CollapsingToolbarLayout? - android

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

Related

How to half overlap frameLyout in android coordinate layout

I want to design a layout like this:
I have use from AppBarLayout and I tried this code:
<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">
<!--tools:layout_marginTop="-200dp">-->
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
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="#android:color/transparent"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:titleEnabled="false">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/banner_detail_course_img"
android:visibility="visible">
<!--<ImageView-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent"-->
<!--android:src="#drawable/banner_detail_course_img"-->
<!--android:scaleType="centerCrop"/>-->
<TextView
android:id="#+id/header_txtTitleCourse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="60dp"
android:layout_marginEnd="10dp"
android:text="#{courseItem.title}"
android:textColor="#fff"
android:textSize="30sp" />
<TextView
android:id="#+id/header_txtShortDescCourse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/header_txtTitleCourse"
android:layout_alignParentEnd="true"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:text="#{courseItem.shortDescription}"
android:textColor="#fff"
android:textSize="15sp" />
<TextView
android:id="#+id/header_txtRate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/header_txtShortDescCourse"
android:layout_alignParentEnd="true"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:background="#drawable/rounded_background_textview"
android:drawableEnd="#drawable/ic_star"
android:drawablePadding="5dp"
android:text="#{String.valueOf(courseItem.ratingAvg)}"
android:textColor="#fff"
android:textSize="15sp" />
<TextView
android:id="#+id/header_txtEnrolled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/header_txtShortDescCourse"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_toStartOf="#+id/header_txtRate"
android:background="#drawable/rounded_background_textview"
android:drawableEnd="#drawable/ic_user_enrolled"
android:drawablePadding="5dp"
android:text="#{courseItem.numberEnroll.concat(#string/space).concat(#string/number_enroll)}"
android:textColor="#fff"
android:textSize="15sp" />
<TextView
android:id="#+id/header_txtDuration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/header_txtRate"
android:layout_alignParentEnd="true"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:background="#drawable/rounded_background_textview"
android:drawableEnd="#drawable/ic_play_icon"
android:drawablePadding="5dp"
android:text="#{courseItem.duration.concat(#string/space).concat(#string/label_hour)}"
android:textColor="#fff"
android:textSize="15sp" />
<TextView
android:id="#+id/header_txtInstructor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/header_txtRate"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_toStartOf="#+id/header_txtDuration"
android:background="#drawable/rounded_background_textview"
android:text="#{#string/txt_label_instructor.concat(#string/space).concat(courseItem.instructorName)}"
android:textColor="#fff"
android:textSize="15sp" />
<TextView
android:id="#+id/header_txtUpdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/header_txtInstructor"
android:layout_alignParentEnd="true"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:background="#drawable/rounded_background_textview"
android:text="#{#string/last_update_course.concat(#string/space).concat(courseItem.updateDate)}"
android:textColor="#FFF"
android:textSize="15sp" />
<FrameLayout
android:id="#+id/flPreview"
android:layout_width="260dp"
android:layout_height="220dp"
android:layout_below="#+id/header_txtUpdate"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp">
<ImageView
android:id="#+id/imgPreview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="#drawable/preview_video_view"
app:imageUrl="#{courseItem.imagePreview}" />
<ImageView
android:id="#+id/imgPlayButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="#drawable/ic_play_video" />
<TextView
android:id="#+id/header_txtPreview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:layout_marginBottom="20dp"
android:text="#string/txt_show_preview_video"
android:textColor="#FFF"
android:textSize="20sp"
android:textStyle="bold" />
</FrameLayout>
</RelativeLayout>
<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/ThemeOverlay.AppCompat.Light">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/imgBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
android:src="#drawable/ic_back_press" />
<ImageView
android:id="#+id/imgFavorit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_toEndOf="#+id/imgShare"
android:src="#drawable/ic_favorite_toolbar" />
<ImageView
android:id="#+id/imgShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
android:src="#drawable/ic_share" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView 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:layout_gravity="fill_vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/txtCurrentPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="30dp"
android:layout_marginEnd="20dp"
android:text="#{courseItem.price}"
android:textSize="30sp"
android:textStyle="bold" />
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
And my output layout is :
I want to be half of FrameLayout preview with id flPreview in the AppBarLayout.
please check this code. this may help you
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="500dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorPrimary"
android:layout_marginBottom="100dp"> <!--just set the half of the size of the frame layout-->
<!--your content here-->
</RelativeLayout>
<FrameLayout
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:background="#color/colorPrimaryDark">
<!--your frame layout content here-->
</FrameLayout>
</RelativeLayout>
</RelativeLayout>
try this on your code.
<?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">
<!--tools:layout_marginTop="-200dp">-->
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="500dp"
android:background="#fff"
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="#android:color/transparent"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:titleEnabled="false">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible">
<!--<ImageView-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent"-->
<!--android:src="#drawable/banner_detail_course_img"-->
<!--android:scaleType="centerCrop"/>-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorPrimaryDark"
android:layout_marginBottom="110dp">
<!-- android:background="#drawable/banner_detail_course_img"-->
<TextView
android:id="#+id/header_txtTitleCourse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="60dp"
android:layout_marginEnd="10dp"
android:text="courseItem.title"
android:textColor="#fff"
android:textSize="30sp" />
<TextView
android:id="#+id/header_txtShortDescCourse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/header_txtTitleCourse"
android:layout_alignParentEnd="true"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:text="courseItem.shortDescription"
android:textColor="#fff"
android:textSize="15sp" />
<TextView
android:id="#+id/header_txtRate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/header_txtShortDescCourse"
android:layout_alignParentEnd="true"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:drawablePadding="5dp"
android:text="courseItem ratingAvg"
android:textColor="#fff"
android:textSize="15sp" />
<!--android:drawableEnd="#drawable/ic_star"
android:background="#drawable/rounded_background_textview"-->
<TextView
android:id="#+id/header_txtEnrolled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/header_txtShortDescCourse"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_toStartOf="#+id/header_txtRate"
android:drawablePadding="5dp"
android:text="#{courseItem.numberEnroll.concat(#string/space).concat(#string/number_enroll)}"
android:textColor="#fff"
android:textSize="15sp" />
<!--android:background="#drawable/rounded_background_textview"
android:drawableEnd="#drawable/ic_user_enrolled"-->
<TextView
android:id="#+id/header_txtDuration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/header_txtRate"
android:layout_alignParentEnd="true"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:drawablePadding="5dp"
android:text="#{courseItem.duration.concat(#string/space).concat(#string/label_hour)}"
android:textColor="#fff"
android:textSize="15sp" />
<!-- android:background="#drawable/rounded_background_textview"
android:drawableEnd="#drawable/ic_play_icon"-->
<TextView
android:id="#+id/header_txtInstructor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/header_txtRate"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_toStartOf="#+id/header_txtDuration"
android:text="#{#string/txt_label_instructor.concat(#string/space).concat(courseItem.instructorName)}"
android:textColor="#fff"
android:textSize="15sp" />
<!-- android:background="#drawable/rounded_background_textview"-->
<TextView
android:id="#+id/header_txtUpdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/header_txtInstructor"
android:layout_alignParentEnd="true"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:text="#{#string/last_update_course.concat(#string/space).concat(courseItem.updateDate)}"
android:textColor="#FFF"
android:textSize="15sp" />
<!-- android:background="#drawable/rounded_background_textview"-->
</RelativeLayout>
<FrameLayout
android:id="#+id/flPreview"
android:layout_width="260dp"
android:layout_height="220dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#color/colorPrimary"
android:layout_marginTop="20dp">
<ImageView
android:id="#+id/imgPreview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
/>
<!-- android:src="#drawable/preview_video_view"-->
<ImageView
android:id="#+id/imgPlayButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#color/colorPrimary"
/>
<!-- android:src="#drawable/ic_play_video"-->
<TextView
android:id="#+id/header_txtPreview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:layout_marginBottom="20dp"
android:text="txt_show_preview_video"
android:textColor="#FFF"
android:textSize="20sp"
android:textStyle="bold" />
</FrameLayout>
</RelativeLayout>
<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/ThemeOverlay.AppCompat.Light">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/imgBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
/>
<!-- android:src="#drawable/ic_back_press"-->
<ImageView
android:id="#+id/imgFavorit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_toEndOf="#+id/imgShare"
/>
<!--android:src="#drawable/ic_favorite_toolbar"-->
<ImageView
android:id="#+id/imgShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
/>
<!-- android:src="#drawable/ic_share"-->
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView 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:layout_gravity="fill_vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/txtCurrentPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="30dp"
android:layout_marginEnd="20dp"
android:text="#{courseItem.price}"
android:textSize="30sp"
android:textStyle="bold" />
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
just change the values and images according to your project

I do not want collapsing toolbar to scroll at all inside coordinator layout

I have a code here which contains of a coordinator layout. Inside that coordinator layout, there is an appbar layout and a nested scrollview beneath it.I want the appbar layout(map) to be still even when nestedscroll view scrolls.I have images to explain my thoughts. Initial stage, stage two. Notice that the map remains still while only nested scroll view scrolls and finally, nested scroll view overlaps entire map fragment.
<?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:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:background="#android:color/white">
<android.support.design.widget.AppBarLayout
android:id="#+id/MyAppbar"
android:layout_width="match_parent"
android:layout_height="550dp"
android:fitsSystemWindows="true"
>
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapse_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true">
<android.support.v7.widget.Toolbar
android:id="#+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="60dp"
app:layout_collapseMode="pin"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/close_button"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_centerVertical="true"
android:src="#drawable/close_black"
/>
<TextView
android:id="#+id/shipping_to_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SHIPPING TO"
android:textColor="#color/black"
android:textStyle="bold"
android:textSize="10dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"/>
<TextView
android:id="#+id/shipping_to"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="926 Rosenbaum Mill"
android:textColor="#color/black"
android:layout_below="#id/shipping_to_title"
android:textSize="16dp"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="550dp"
tools:context=".MapFragment"
android:layout_below="#id/my_toolbar"
app:layout_collapseMode="pin"
>
<RelativeLayout
android:id="#+id/outermost_wrapper"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
android:id="#+id/bottom_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="20dp"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_centerHorizontal="true"
>
<include
android:id="#+id/getDirections"
layout="#layout/track_shipment_activity_get_directions_fragment_layout"
android:visibility="gone"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true"
/>
<include
android:id="#+id/received"
layout="#layout/track_shipment_activity_received_fragment_layout"
android:visibility="gone"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true"
/>
<include
android:id="#+id/enrouteToDestination"
layout="#layout/track_shipment_activity_button_fragment_layout"
android:visibility="gone"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true"
/>
<include
android:id="#+id/trackOrder"
layout="#layout/track_shipment_track_order_button_fragment_layout"
android:visibility="gone"
/>
<RelativeLayout
android:id="#+id/trackOrderBelow"
android:layout_width="300dp"
android:layout_height="40dp"
android:layout_below="#id/trackOrder"
android:layout_marginBottom="20dp"
android:background="#FBFBFB"
android:layout_centerHorizontal="true"
android:visibility="gone">
<TextView
android:id="#+id/tracking_code_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/tracking_code"
android:textSize="14dp"
android:textColor="#color/black"
android:layout_marginStart="10dp"
android:layout_centerVertical="true"/>
<TextView
android:id="#+id/tracking_code"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/tracking_code_numbers"
android:layout_toRightOf="#id/tracking_code_title"
android:textSize="14dp"
android:textColor="#color/black"
android:layout_marginStart="10dp"
android:layout_centerVertical="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/double_boxes"
android:layout_alignParentEnd="true"
android:layout_marginEnd="10dp"
android:layout_centerVertical="true"/>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
</fragment>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView 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:layout_gravity="fill_vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<RelativeLayout xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/abc"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/MyAppbar"
android:layout_marginTop="30dp"
tools:context=".MapFragment">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ScrollView
android:id="#+id/scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/relative_layout_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/activity_background">
<RelativeLayout
android:id="#+id/relative_layout_inner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:focusedByDefault="true">
<ImageView
android:id="#+id/order_icon"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginStart="15dp"
android:layout_marginTop="25dp"
android:contentDescription="#string/app_name"
android:src="#drawable/orders" />
<TextView
android:id="#+id/order_date_title"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_marginTop="25dp"
android:layout_toEndOf="#id/order_icon"
android:gravity="center"
android:paddingLeft="5dp"
android:text="#string/order_date2"
android:textColor="#android:color/black" />
<TextView
android:id="#+id/order_date"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignParentEnd="true"
android:layout_marginEnd="15dp"
android:layout_marginTop="25dp"
android:layout_toEndOf="#id/order_date_title"
android:gravity="center|end"
android:paddingLeft="90dp"
android:text="#string/date5"
android:textColor="#android:color/black"
android:textStyle="bold" />
<ImageView
android:id="#+id/placeBy_icon"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_below="#id/order_icon"
android:layout_marginStart="15dp"
android:layout_marginTop="20dp"
android:contentDescription="#string/app_name"
android:src="#drawable/person" />
<TextView
android:id="#+id/placed_by_title"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_below="#id/order_date_title"
android:layout_marginTop="20dp"
android:layout_toEndOf="#id/placeBy_icon"
android:gravity="center"
android:paddingLeft="5dp"
android:text="#string/placed_by"
android:textColor="#android:color/black" />
<TextView
android:id="#+id/placed_by"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignParentEnd="true"
android:layout_below="#id/order_date_title"
android:layout_marginEnd="15dp"
android:layout_marginTop="20dp"
android:layout_toEndOf="#id/placed_by_title"
android:gravity="center|end"
android:paddingLeft="100dp"
android:text="#string/user_name"
android:textColor="#android:color/black"
android:textStyle="bold" />
<ImageView
android:id="#+id/delivery_icon"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_below="#id/placeBy_icon"
android:layout_marginStart="15dp"
android:layout_marginTop="20dp"
android:contentDescription="#string/app_name"
android:src="#drawable/delivery" />
<TextView
android:id="#+id/delivery_method_title"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_below="#id/placed_by_title"
android:layout_marginTop="20dp"
android:layout_toEndOf="#id/delivery_icon"
android:gravity="center"
android:paddingLeft="5dp"
android:text="#string/delivery_method"
android:textColor="#android:color/black" />
<TextView
android:id="#+id/delivery_method"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignParentEnd="true"
android:layout_below="#id/placed_by_title"
android:layout_marginEnd="15dp"
android:layout_marginTop="20dp"
android:layout_toEndOf="#id/delivery_method_title"
android:gravity="center|end"
android:text="#string/shipping"
android:textColor="#android:color/black"
android:textStyle="bold" />
<RelativeLayout
android:id="#+id/add_to_calander_button_shipment"
android:layout_width="340dp"
android:layout_height="40dp"
android:layout_below="#+id/delivery_icon"
android:layout_centerHorizontal="true"
android:layout_marginBottom="20dp"
android:layout_marginTop="20dp"
android:background="#drawable/add_to_calander">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true">
<ImageView
android:id="#+id/addToCalIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/app_name"
android:src="#drawable/orders" />
<TextView
android:id="#+id/addToCalText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginTop="2dp"
android:layout_toEndOf="#id/addToCalIcon"
android:text="#string/add_to_calander"
android:textSize="14dp" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
<View
android:id="#+id/threeItems"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="#+id/relative_layout_inner"
android:layout_marginStart="10dp"
android:layout_marginTop="30dp"
android:background="#color/activity_background" />
<TextView
android:id="#+id/threeItemstext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relative_layout_inner"
android:layout_marginStart="10dp"
android:layout_marginTop="30dp"
android:text="#string/number_of_items"
android:textColor="#color/black"
android:textSize="16dp"
android:textStyle="bold" />
<android.support.v4.widget.NestedScrollView
android:id="#+id/nestedRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/threeItems">
<android.support.v7.widget.RecyclerView
android:id="#+id/simpleRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white"
android:nestedScrollingEnabled="false"
app:layout_behavior="#string/app_bar_scrolling_view_behavior">
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.NestedScrollView>
<include
android:id="#+id/delivery_details"
layout="#layout/track_shipment_delivery_details_fragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/nestedRecyclerView"
android:layout_marginBottom="5dp"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp" />
<include
android:id="#+id/order"
layout="#layout/track_shipment_order_total_fragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/delivery_details"
android:layout_marginBottom="5dp"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:layout_marginTop="5dp" />
<include
android:id="#+id/need_help"
layout="#layout/track_shipment_need_help_fragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/order"
android:layout_marginBottom="10dp"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:layout_marginTop="5dp" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
Try adding
app:behavior_overlapTop="0dp" in your nested scroll view and also add some elevation to the nested scroll view.

NestedScrollView doesnt show cards with wrap content and dynamic data

I have an activity with view pager and I'm loading fragments which has NestedScrollView as parent with cards in it. The data in the card is loaded dynamically and doesn't have fixed height. The card's height is set to wrap_content.
The problem is that the NestedScrollView is not displaying the cards properly after the data is loaded. In some cases the cards overlap each other, while in some, the cards are not visible at all (usually the last).
The activity:
<?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:id="#+id/activity_generic_candidate_profile"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.interviewair.interviewairforemployer.ui.genericCandidateProfile.GenericCandidateProfileActivity">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbarlayout_all"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsingtoolbar_genericcandidateprofile"
android:layout_width="match_parent"
android:layout_height="300dp"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleTextAppearance="#android:color/transparent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="150dp">
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.5"
android:background="#color/black" />
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#drawable/ic_play_circle_outline_black_24px"
android:tint="#color/white"
android:elevation="10dp"
android:alpha="0.7"
android:layout_gravity="center"/>
</FrameLayout>
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/circleimageview_genericcandidateprofile_photo"
android:layout_width="75dp"
android:layout_height="75dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="#dimen/margin_10"
android:src="#drawable/ic_person_outline_white_48px"
app:civ_border_color="#color/white"
app:civ_border_width="1.5dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="30dp"
android:layout_marginStart="#dimen/margin_10"
android:orientation="vertical">
<TextView
android:id="#+id/textview_genericcandidateprofile_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/margin_5"
android:drawablePadding="#dimen/padding_5"
android:gravity="center_vertical"
android:textColor="#color/white"
android:textSize="#dimen/di_text_medium"
android:textStyle="bold" />
<TextView
android:id="#+id/textview_genericcandidateprofile_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/margin_5"
android:alpha="0.8"
android:drawableLeft="#drawable/ic_work_black_18dp"
android:drawablePadding="#dimen/padding_5"
android:gravity="center_vertical"
android:textColor="#color/white"
android:textSize="#dimen/di_text_regular" />
<TextView
android:id="#+id/textview_genericcandidateprofile_location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/margin_5"
android:alpha="0.8"
android:drawableLeft="#drawable/ic_location_on_black_18px"
android:drawablePadding="#dimen/padding_5"
android:gravity="center_vertical"
android:text="Mumbai, Maharashtra"
android:textColor="#color/white"
android:textSize="#dimen/di_text_regular" />
</LinearLayout>
</FrameLayout>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar_genericcandidateprofile"
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.TabLayout
android:id="#+id/tablayout_genericcandidateprofile_tab"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_collapseMode="pin"
app:tabGravity="fill"
app:tabIndicatorColor="#color/white"
app:tabIndicatorHeight="5dp"
app:tabMode="scrollable"
app:tabSelectedTextColor="#color/white"
app:tabTextColor="#color/grey500" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/viewpager_genericcandidateprofile_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginEnd="#dimen/fab_margin"
android:layout_marginBottom="#dimen/fab_margin"
app:borderWidth="0dp"
app:elevation="6dp"
app:pressedTranslationZ="12dp"
android:clickable="true"
app:rippleColor="#color/colorPrimary"
android:src="#drawable/ic_dashboard_white_24px"/>
</android.support.design.widget.CoordinatorLayout>
The fragment that is being loaded:
<android.support.v7.widget.CardView
android:id="#+id/cardview_overview_skills"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/margin_5">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="#dimen/padding_10">
<TextView
android:id="#+id/textview_overview_skilltitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawablePadding="#dimen/padding_5"
android:gravity="center_vertical"
android:text="#string/text_skills"
android:textColor="#color/colorPrimary"
android:textSize="#dimen/di_text_regular" />
<com.dpizarro.autolabel.library.AutoLabelUI
android:id="#+id/autolabel_overview_skillchips"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/textview_overview_skilltitle"
android:layout_marginTop="#dimen/margin_10"
autolabel:label_background_res="#drawable/custom_rounded_background"
autolabel:label_clickable="false"
autolabel:show_cross="false"
autolabel:text_color="#android:color/black"
autolabel:text_size="#dimen/di_text_small" />
<ImageView
android:id="#+id/imageview_overview_retry_skills"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_centerInParent="true"
android:background="#drawable/custom_button_grey_background"
android:src="#drawable/ic_refresh_black_24px"
android:tint="#color/colorAccent"
android:visibility="gone" />
<ProgressBar
android:id="#+id/progressbar_overview_skillpb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:indeterminate="true"
android:visibility="gone" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/cardview_overview_preferredlocation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/cardview_overview_skills"
android:layout_margin="#dimen/margin_5">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="#dimen/padding_10">
<TextView
android:id="#+id/textview_overview_loctitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/text_preferred_location"
android:textColor="#color/colorPrimary"
android:textSize="#dimen/di_text_regular" />
<com.dpizarro.autolabel.library.AutoLabelUI
android:id="#+id/autolabel_overview_preflocchips"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/textview_overview_loctitle"
android:layout_marginTop="#dimen/margin_10"
autolabel:label_background_res="#drawable/custom_rounded_background"
autolabel:label_clickable="false"
autolabel:show_cross="false"
autolabel:text_color="#android:color/black"
autolabel:text_size="#dimen/di_text_small" />
<ImageView
android:id="#+id/imageview_overview_retry_loc"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_centerInParent="true"
android:background="#drawable/custom_button_grey_background"
android:src="#drawable/ic_refresh_black_24px"
android:tint="#color/colorAccent"
android:visibility="gone" />
<ProgressBar
android:id="#+id/progressbar_overview_locpb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:indeterminate="true"
android:visibility="gone" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/cardview_overview_personal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/cardview_overview_eduexp"
android:layout_margin="#dimen/margin_5">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="#dimen/padding_5">
<TextView
android:id="#+id/textview_overview_personaltitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawablePadding="#dimen/padding_5"
android:gravity="center_vertical"
android:text="#string/text_personal"
android:textColor="#color/colorPrimary"
android:textSize="#dimen/di_text_regular" />
<LinearLayout
android:id="#+id/linearlayout_overview_personalwrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/margin_5"
android:layout_marginTop="#dimen/margin_10"
android:orientation="vertical"
android:visibility="gone">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="75dp"
android:layout_height="wrap_content"
android:text="#string/text_email"
android:textColor="#color/grey700"
android:textSize="#dimen/di_text_regular" />
<TextView
android:id="#+id/textview_overview_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:textSize="#dimen/di_text_regular" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_5"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="75dp"
android:layout_height="wrap_content"
android:text="#string/text_mobile"
android:textColor="#color/grey700"
android:textSize="#dimen/di_text_regular" />
<TextView
android:id="#+id/textview_overview_mobile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:textSize="#dimen/di_text_regular" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_5"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="75dp"
android:layout_height="wrap_content"
android:text="#string/text_dob"
android:textColor="#color/grey700"
android:textSize="#dimen/di_text_regular" />
<TextView
android:id="#+id/textview_overview_dob"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:textSize="#dimen/di_text_regular" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_5"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="75dp"
android:layout_height="wrap_content"
android:text="#string/text_gender"
android:textColor="#color/grey700"
android:textSize="#dimen/di_text_regular" />
<TextView
android:id="#+id/textview_overview_gender"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:textSize="#dimen/di_text_regular" />
</LinearLayout>
</LinearLayout>
<ImageView
android:id="#+id/imageview_overview_retry_personal"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:background="#drawable/custom_button_grey_background"
android:src="#drawable/ic_refresh_black_24px"
android:tint="#color/colorAccent"
android:visibility="gone" />
<ProgressBar
android:id="#+id/progressbar_overview_personalpb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:indeterminate="true"
android:visibility="gone" />
</LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>

CollapsingToolbarLayout collapsed with nested scrollview by default

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.

Pull down zoom view inside the android collapsing layout

Collapsing layout image will only collapse and expand. Pull-down zoom view is not supported in the nested scroll view. If we zoom in on the image it does not actually zoom. What is the solution to zooming the image during pull down?
<?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/editprofilelayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
>
​
<android.support.design.widget.AppBarLayout
android:id="#+id/materialup_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#null"
android:fitsSystemWindows="true"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
>
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/main.collapsing"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:contentScrim="#android:color/transparent"
android:fitsSystemWindows="true"
app:expandedTitleTextAppearance="#android:color/transparent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
>
​
<ImageView
android:id="#+id/materialup.profile_backdrop"
android:layout_width="match_parent"
android:layout_height="150dp"
android:scaleType="centerCrop"
android:src="#color/app_color"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7"
/>0
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/profile_image"
android:layout_width="76dp"
android:layout_height="76dp"
android:layout_marginTop="100dp"
android:layout_marginLeft="20dp"
android:layout_gravity="left"
android:src="#drawable/profileicon"
android:background="#null"
app:border_width="0dp"
app:border_color="#FFF"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7"
/>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#null"
app:layout_collapseMode="pin"
android:fitsSystemWindows="true"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
android:foreground="?android:windowActionBarOverlay"
style="#style/ToolBarWithNavigationBack">
<TextView
style="#style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:id="#+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:visibility="gone"
android:layout_height="wrap_content"
android:textColor="#color/white" />
</android.support.v7.widget.Toolbar>
<ImageButton
android:id="#+id/editbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_edit_profile"
android:layout_marginTop="15dp"
android:layout_marginRight="20dp"
android:background="#null"
android:fitsSystemWindows="true"
android:nestedScrollingEnabled="false"
android:layout_gravity="center_horizontal|end"/>
<ImageButton
android:id="#+id/morebutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_more_white"
android:visibility="invisible"
android:layout_marginTop="20dp"
android:layout_marginRight="20dp"
android:background="#null"
android:fitsSystemWindows="true"
android:nestedScrollingEnabled="false"
android:layout_gravity="center_horizontal|end"/>
<LinearLayout
android:id="#+id/materialup.title_containermain2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="155dp"
android:clipChildren="false"
android:clipToPadding="false"
android:background="#null"
android:orientation="vertical"
android:gravity="center"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
>
<LinearLayout
android:id="#+id/materialup.title_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#null"
android:orientation="vertical"
android:gravity="center"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:id="#+id/layout3"
android:clipChildren="false"
android:clipToPadding="false"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7"
android:background="#null"
>
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:id="#+id/imageButton6"
android:layout_toLeftOf="#+id/editprofile"
android:layout_marginRight="15dp"
android:src="#drawable/ic_settings_profile"/>
<Button
android:layout_width="100dp"
android:layout_height="25dp"
android:id="#+id/editprofile"
android:text="Edit Profile"
android:textColor="#ffffff"
android:background="#drawable/rounded_corner_profile"
android:textSize="15dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_alignTop="#+id/imageButton6"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="11dp"
android:layout_marginEnd="18dp" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="#null"
android:background="#drawable/customcheckbox"
android:visibility="invisible"
android:gravity="center_horizontal"
android:id="#+id/follow"
android:layout_alignBottom="#+id/username"
android:layout_alignRight="#+id/editprofile"
android:layout_alignEnd="#+id/editprofile" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="18dp"
android:textStyle="bold"
android:id="#+id/username"
android:textColor="#000000"
android:layout_marginTop="30dp"
android:layout_marginLeft="18dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="12dp"
android:layout_below="#+id/username"
android:id="#+id/bio"
android:textColor="#000000"
android:layout_marginTop="10dp"
android:layout_marginLeft="18dp"
/>
<ImageView
android:layout_width="15dp"
android:layout_height="wrap_content"
android:id="#+id/image4"
android:layout_below="#+id/bio"
android:src="#drawable/ic_link"
android:layout_alignBottom="#+id/website"
android:layout_marginLeft="18dp"
android:layout_marginTop="15dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="12dp"
android:textColor="#color/app_color"
android:id="#+id/website"
android:layout_below="#+id/bio"
android:layout_toRightOf="#+id/image4"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="FOLLOWERS"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="12dp"
android:id="#+id/followers"
android:layout_below="#+id/image4"
android:layout_toRightOf="#+id/followercount"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="12dp"
android:textColor="#color/app_color"
android:id="#+id/followercount"
android:layout_below="#+id/image4"
android:layout_marginLeft="18dp"
android:layout_marginTop="10dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/app_color"
android:text="0"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="12dp"
android:id="#+id/followingcount"
android:layout_below="#+id/image4"
android:layout_toRightOf="#+id/followers"
android:layout_marginLeft="18dp"
android:layout_marginTop="10dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="FOLLOWING"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="12dp"
android:id="#+id/following"
android:layout_below="#+id/image4"
android:layout_toRightOf="#+id/followingcount"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
/>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</android.support.design.widget.CollapsingToolbarLayout>
<android.support.design.widget.TabLayout
android:id="#+id/tabs1"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="#color/white"
app:tabSelectedTextColor="#color/app_color"
app:tabTextColor="#color/app_color"
app:tabIndicatorHeight="2dp"
app:tabIndicatorColor="#color/app_color"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll"
app:tabMode="fixed"
/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:id="#+id/nest_scrollview"
android:fillViewport="true"
android:layout_gravity="fill_vertical"
>
</android.support.v4.widget.NestedScrollView>
<com.cogzidel.hotfuse.NonSwipeableViewPager
android:id="#+id/materialup_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
/>
</android.support.design.widget.CoordinatorLayout>

Categories

Resources