How to half overlap frameLyout in android coordinate layout - android

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

Related

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.

Grid view scrolling is not working in android

I am developing an android application in my application I wanted to use CollapsingToolbarLayout and GridView in a same page.The CollapsingToolBar is working properly. But My GridView Scrolling is not working.
activity_health.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/activity_offer_details"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="akhil.com.d4d.activities.OfferDetails">
<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="wrap_content"
app:contentScrim="?attr/colorPrimary"
android:fitsSystemWindows="true"
android:background="#E7E7E7"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<!--
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar1"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />-->
<RelativeLayout
android:id="#+id/Rlayout_H_menus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:paddingLeft="15dp"
android:layout_marginRight="15dp"
android:paddingTop="15dp"
android:id="#+id/layoutmenu1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/menu_offers"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="55dp"
android:layout_height="55dp"
android:background="#drawable/roundblue"
android:scaleType="center"
android:src="#drawable/offer" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Offers"
android:textColor="#color/black" />
</LinearLayout>
<LinearLayout
android:id="#+id/menu_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="13dp"
android:layout_toRightOf="#+id/menu_offers"
android:orientation="vertical">
<ImageView
android:layout_width="55dp"
android:layout_height="55dp"
android:background="#drawable/roundblue"
android:scaleType="center"
android:src="#drawable/menu" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Menu"
android:textColor="#color/black" />
</LinearLayout>
<LinearLayout
android:id="#+id/menu_exchange"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="13dp"
android:layout_toRightOf="#+id/menu_menu"
android:orientation="vertical">
<ImageView
android:id="#+id/img_exchange"
android:layout_width="55dp"
android:layout_height="55dp"
android:background="#drawable/roundblue"
android:scaleType="center"
android:src="#drawable/exchange" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Exchange"
android:textColor="#color/black" />
</LinearLayout>
<LinearLayout
android:id="#+id/menu_health"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="13dp"
android:layout_toRightOf="#+id/menu_exchange"
android:orientation="vertical">
<ImageView
android:layout_width="55dp"
android:layout_height="55dp"
android:background="#drawable/roundblue"
android:scaleType="center"
android:src="#drawable/health" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Health"
android:textColor="#color/black" />
</LinearLayout>
<LinearLayout
android:id="#+id/menu_less"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="13dp"
android:layout_toRightOf="#+id/menu_health"
android:orientation="vertical">
<ImageView
android:id="#+id/img_less_more"
android:layout_width="55dp"
android:layout_height="55dp"
android:background="#drawable/roundblue"
android:scaleType="center"
android:src="#drawable/less" />
<TextView
android:id="#+id/txt_less_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Less"
android:textColor="#color/black" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:paddingLeft="15dp"
android:layout_marginRight="15dp"
android:id="#+id/layoutmenu2"
android:layout_below="#+id/layoutmenu1"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:id="#+id/menu_bank"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/menu_offers"
android:layout_marginTop="10dp"
android:orientation="vertical">
<ImageView
android:layout_width="55dp"
android:layout_height="55dp"
android:background="#drawable/roundblue"
android:scaleType="center"
android:src="#drawable/bank" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Bank"
android:textColor="#color/black" />
</LinearLayout>
<LinearLayout
android:id="#+id/menu_sos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/menu_menu"
android:layout_marginLeft="13dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/menu_bank"
android:orientation="vertical">
<ImageView
android:layout_width="55dp"
android:layout_height="55dp"
android:background="#drawable/roundblue"
android:scaleType="center"
android:src="#drawable/sos" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="SOS"
android:textColor="#color/black" />
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_marginTop="10dp"
android:id="#+id/layoutImage"
app:layout_collapseMode="parallax"
android:layout_below="#+id/layoutmenu2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!--
<ImageView
android:layout_width="match_parent"
android:layout_height="150dp"
android:src="#drawable/hospital_health"
android:scaleType="centerCrop"/>-->
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:background="#FFF"
android:layout_height="150dp">
</android.support.v4.view.ViewPager>
<com.viewpagerindicator.CirclePageIndicator
android:id="#+id/indicator"
android:layout_width="fill_parent"
android:layout_height="22dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="125dp"
android:padding="10dip"
app:centered="true"
app:fillColor="#FFFFFF"
app:snap="false" />
</RelativeLayout>
</RelativeLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="#+id/nested_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<akhil.com.d4d.common.ExpandableHeightGridView
android:id="#+id/health_grid"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:gravity="center"
android:background="#E7E7E7"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:numColumns="2"
android:layout_weight="1">
</akhil.com.d4d.common.ExpandableHeightGridView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
<!--
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_health"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="akhil.com.d4d.activities.Health">
</RelativeLayout>-->

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>

how to hide image view on coordinate layout (like fab hide on scroll)?

I want to hide/disappear Image view(like fab) when its scroll as its coordinate layout behavior currently its behave like this first
while scroll
and this
and this is my layout xml
<RelativeLayout 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">
<LinearLayout
android:id="#+id/lyoutFeedLoadMore"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:background="#FAFAFA"
android:gravity="center"
android:visibility="gone">
<ProgressBar
android:id="#+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<View
android:id="#+id/bottomView"
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_alignParentBottom="true"
android:background="#color/white" />
<android.support.design.widget.CoordinatorLayout
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.photex.urdu.textonphotos.activities.ScrollingActivity"
android:layout_above="#+id/bottomView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<android.support.design.widget.AppBarLayout
android:id="#+id/main.appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:fitsSystemWindows="true"
android:orientation="vertical"
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="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white">
<FrameLayout
android:id="#+id/main.framelayout.title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/main.backCover"
android:layout_gravity="bottom"
android:layout_marginLeft="120dp"
android:layout_marginStart="120dp"
android:background="#color/white"
android:orientation="vertical"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.3">
<LinearLayout
android:id="#+id/pfInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="horizontal"
android:weightSum="3">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginStart="12dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/txtCountPost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="-"
android:textColor="#android:color/black"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/txtPost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="post"
android:textColor="#android:color/black" />
</LinearLayout>
<LinearLayout
android:id="#+id/layout_followers"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/txtCountFollowers"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="-"
android:textColor="#android:color/black"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/txtFollowers"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="followers"
android:textColor="#android:color/black" />
</LinearLayout>
<LinearLayout
android:id="#+id/layout_following"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/txtCountFollowing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="-"
android:textColor="#android:color/black"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/txtFollowing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="following"
android:textColor="#android:color/black" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
<LinearLayout
android:id="#+id/main.section"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/main.framelayout.title"
android:layout_margin="16dp"
android:orientation="vertical">
<TextView
android:id="#+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:text="nasdnfasdnfasdhfjasdhfahsdfahsdasdfa"
android:textColor="#android:color/black"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/txtBio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:ellipsize="end"
android:maxLines="5"
android:text="fgsfgdfgsdfgdfg"
android:textColor="#android:color/black"
android:textSize="16sp"
android:visibility="visible" />
<TextView
android:id="#+id/txtFallowedBy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:ellipsize="end"
android:maxLines="2"
android:text="Success Diaries"
android:textColor="#android:color/black"
android:textSize="16sp"
android:visibility="gone" />
</LinearLayout>
<Button
android:id="#+id/btnFollowEdit"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_below="#+id/main.section"
android:layout_centerInParent="true"
android:background="#drawable/bg_rectangle_white"
android:minWidth="150dp"
android:onClick="onClick"
android:text="Follow"
android:textColor="#android:color/black"
android:visibility="visible" />
<View
android:id="#+id/view"
android:layout_width="match_parent"
android:layout_height="32dp"
android:layout_below="#+id/btnFollowEdit"
android:layout_marginBottom="12dp"
android:visibility="invisible" />
<ImageView
android:id="#+id/main.backCover"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
android:src="#drawable/sea"
app:layout_collapseMode="parallax" />
</RelativeLayout>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbarUser"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="#style/AppTheme.PopupOverlay">
<TextView
android:id="#+id/txtNameToolbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#android:color/white"
android:textSize="18sp" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<ProgressBar
android:id="#+id/progressBarMain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="300dp" />
<android.support.v7.widget.RecyclerView
android:id="#+id/rvFeeds"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/srlContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<android.support.v7.widget.RecyclerView
android:id="#+id/rvUserFeeds"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</android.support.v4.widget.SwipeRefreshLayout>
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/ivUserProfilePhoto"
android:layout_width="92dp"
android:layout_height="92dp"
android:layout_margin="#dimen/fab_margin"
android:src="#mipmap/ic_launcher"
app:civ_border_width="2dp"
app:layout_anchor="#id/main.backCover"
app:layout_anchorGravity="bottom|left|end" />
</android.support.design.widget.CoordinatorLayout>
</RelativeLayout>
what i exactly want behavior like facebook scroll
first
on scrolling ]6
Try to make your Parent layout as android.support.design.widget.CoordinatorLayout then set all your content inside that layout Check this.
<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:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="192dp"
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="?attr/colorPrimary"
app:expandedTitleMarginBottom="32dp"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/header"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="#+id/anim_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/scrollableview"
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_margin="#dimen/fab_margin"
android:clickable="true"
android:src="#drawable/ic_action_add"
app:layout_anchor="#+id/appbar"
app:layout_anchorGravity="bottom|right|end" />
</android.support.design.widget.CoordinatorLayout>

How to implement snapping in CollapsingToolbarLayout?

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

Categories

Resources