Coordinator Layout content is showing behind the status bar - android

I'm building a toolbar with a map fragment as part of it. The toolbar is fixed in position and is opaque.
Whenever the view's content is scrolled upwards, the map fragment moves with it but it is visible above the toolbar (and therefore between the status bar itself and the statusbar's orange background).
This is the resulting issue:
If I scroll a bit more, the scrim fades in normally, but too late.
Is there a way of not drawing the content when it goes above the toolbar? Or a way of making the status bar background to be drawn in front of the AppBarLayout content?
I've tried drawing a view in front of the AppBarLayout (right below the statusbar), but once the MapFragment is scrolled all the way up, it is then brought to front of that view, making the MapFragment visible during a small instant.
<?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:clickable="true"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="#dimen/promotion_details_image_height"
android:clickable="true"
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:background="#color/orange"
android:fitsSystemWindows="true"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize">
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_collapseMode="none"
tools:context=".restaurants.stores.StoresFragment" />
<ImageView
android:id="#+id/minimizeBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/stores_details_minimize_margin"
android:clickable="true"
android:contentDescription="#null"
android:paddingTop="#dimen/status_bar_height"
android:src="#drawable/selector_map_minimize_btn"
android:visibility="gone" />
<include
android:id="#+id/cardDetailsLayout"
layout="#layout/store_card_small_detail"
android:layout_width="match_parent"
android:layout_height="#dimen/stores_details_card_height"
android:layout_alignParentBottom="true"
android:layout_margin="10dp"
android:visibility="gone" />
</RelativeLayout>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light">
<com.app.views.FontTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true"
android:text="#string/store_toolbar_text"
android:textColor="#color/white"
android:textSize="#dimen/toolbar_text_size"
app:font="#string/fontFlamaMedium" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
Edit:
In the layout xml the android:layout_behavior attribute associated with my RecyclerView, but the toolbar's content has the correct behaviour, the problem is that it is visible under the statusbar, which I don't want it to.

You should remove your argument:android:fitsSystemWindows="true"
More about this on this blogPost from a google developper :
https://medium.com/google-developers/why-would-i-want-to-fitssystemwindows-4e26d9ce1eec

Remove this attribute from Toolbar
android:background="?attr/colorPrimary"
And add this attribute to CollapsingToolbar
app:contentScrim="?attr/colorPrimary"
The contentScrim will control the color of the Toolbar and ensure the color only appears when the background image has faded out

Related

CollapsingToolbarLayout with two views, make one scroll but not the other

I have an activity with a toolbar and a recyclerview. On top of the recyclerview I have a panel that I want to be scrollable (to move along with the scroll of the recyclerview).
I want this panel to scroll behind the toolbar, so when the scrolling happens, the toolbar stays in place and the panel slides behind it.
Kind of what they do here:
https://i.imgur.com/fQA6bPH.gif
But I cant find the right combination of options with CollapsingToolbarLayout to achieve this effect:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
tools:context=".ui.profile.ProfileActivity">
<android.support.design.widget.AppBarLayout
android:id="#+id/profile_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/topbar_gradient"
android:theme="#style/AppTheme.Dark">
<android.support.design.widget.CollapsingToolbarLayout
android:orientation="vertical"
android:id="#+id/detail_collapsing"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="#drawable/topbar_gradient"
app:layout_collapseMode="none"
android:minHeight="?android:attr/actionBarSize" />
<LinearLayout
android:layout_marginTop="?actionBarSize"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_collapseMode="none"
app:layout_collapseParallaxMultiplier="0.5">
...
</LinearLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
(...)
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>
To simplify, I've changed the structure to this:
<android.support.design.widget.CollapsingToolbarLayout
android:orientation="vertical"
android:id="#+id/detail_collapsing"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="?colorPrimary"
android:fitsSystemWindows="true"
app:layout_scrollFlags="scroll|enterAlways">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="#drawable/topbar_gradient"
app:layout_collapseMode="pin"
android:minHeight="?android:attr/actionBarSize" />
<LinearLayout
android:layout_marginTop="?actionBarSize"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.5">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="#drawable/bar"/>
</LinearLayout>
</android.support.design.widget.CollapsingToolbarLayout>
It does exactly the same when we add an ImageView inside the CollapsingToolbarLayout like this with parallax flag of app:layout_collapseMode:
<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:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="pin" />
<ImageView
android:src="#drawable/cheese_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax" //Here is the solution
android:minHeight="100dp" />
</android.support.design.widget.CollapsingToolbarLayout>
So you may want to add :
app:layout_collapseMode="parallax"
To your view (LinearLayout) or anything inside.
Read: https://guides.codepath.com/android/handling-scrolls-with-coordinatorlayout#creating-parallax-animations
I solved this problem by moving Toolbar outside of AppBarLayout. Then in code setup Toolbar as SupportActionBar.
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
tools:context=".ui.profile.ProfileActivity">
<android.support.design.widget.AppBarLayout
android:id="#+id/profile_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/topbar_gradient"
android:theme="#style/AppTheme.Dark">
<android.support.design.widget.CollapsingToolbarLayout
android:orientation="vertical"
android:id="#+id/detail_collapsing"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:layout_scrollFlags="scroll|enterAlways">
<LinearLayout
android:layout_marginTop="?actionBarSize"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_collapseMode="pin">
...
</LinearLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
(...)
</FrameLayout>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="#drawable/topbar_gradient"
android:minHeight="?android:attr/actionBarSize" />
</android.support.design.widget.CoordinatorLayout>
You need to change this to get desired effect:
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/detail_collapsing"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical"
app:contentScrim="?colorPrimary"
app:layout_scrollFlags="scroll|enterAlwaysCollapsed|exitUntilCollapsed"
app:titleEnabled="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="?actionBarSize"
android:orientation="vertical"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.5">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="#drawable/bar" />
</LinearLayout>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="#drawable/topbar_gradient"
android:minHeight="?android:attr/actionBarSize"
app:layout_collapseMode="pin" />
</android.support.design.widget.CollapsingToolbarLayout>
Your change was in CollapsingToolbar, by using these three attributes "scroll|enterAlwaysCollapsed|exitUntilCollapsed" together will change that effect.
Description :
app:layout_collapseMode="" is attribute used to collapse/pin child views of CollapsingToolbarLayout.
There are three attributes to this :
none : No effects at all.
pin : Pin that view at CollapsingToolbar when scrolled.
parallax : Hide view parallel with CollapsingToolbar hiding.
so if you're having Toolbar pinned to CollapsingToolbarLayout then add this property pin (which will pin it to Collapsing toolbar when scrolled) and parallax will animate it until collapsed.
Let's see
How does scrolling actually works using these 4 attributes in
app:layout_scrollFlags=""
scroll : The view will be scroll in direct relation to scroll
events.(Necessary, otherwise any other attribute won't work)
enterAlways : When entering (scrolling on screen) the view will
scroll on any downwards scroll event, regardless of whether the
scrolling view is also scrolling.
enterAlwaysCollapsed : An additional flag for 'enterAlways' which
modifies the returning view to only initially scroll back to it's
collapsed height.
exitUntilCollapsed : When exiting (scrolling off screen) the view
will be scrolled until it is 'collapsed'.
snap : Upon a scroll ending, if the view is only partially visible
then it will be snapped and scrolled to it's closest edge.
More details from here & demo here
Findout more from here : link

Android parallax effect CollapsingToolbarLayout with ViewGroup Layout is not working

I am developing an Android app. In my app, I am using CollapsingToolbarLayout for parallax effect. Before I used AppbarLayout, CollapsingToolbarLayout together with ViewPager, I was working fine. But this time, I replaced view holder for content with RelativeLayout. So when I scroll up from the content, toolbar is not collapsed. I mean when I scroll up from the position I circled in the screenshot below.
But if I scroll up from the toolbar area, it is working. I mean the area in the screenshot.
This is my XML layout
<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:background="#android:color/background_light"
android:fitsSystemWindows="true"
>
<android.support.design.widget.AppBarLayout
android:id="#+id/ai_app_bar"
android:layout_width="match_parent"
android:layout_height="300dp"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true"
>
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/main.collapsing"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp"
>
<RelativeLayout
android:background="#drawable/item"
app:layout_collapseMode="parallax"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:background="#color/lightGray"
android:layout_width="match_parent"
android:layout_height="match_parent"></View>
</RelativeLayout>
<android.support.v7.widget.Toolbar
android:id="#+id/ai_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin"
/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<RelativeLayout
app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="This is testing"
android:textColor="#color/textColorPrimary"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/ai_review_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:src="#android:drawable/btn_star"
android:layout_margin="10dp"
android:visibility="gone"
app:layout_anchor="#id/ai_app_bar"
app:layout_anchorGravity="bottom|right|end"
/>
</android.support.design.widget.CoordinatorLayout>
Why toolbar is not collapsed when I scroll up from the relative layout area? How can I fix that to be the toolbar collapsed if I scroll up from the RelativeLayout area?
You should use RecyclerView instead of RelativeLayout outside of the AppBarLayout and add this view tag to it app:layout_behavior="#string/appbar_scrolling_view_behavior"
string/appbar_scrolling_view_behavior maps to
AppBarLayout.ScrollingViewBehavior, which is used to notify the
AppBarLayout when scroll events occur on this particular view.
From here Handling Scrolls with CoordinatorLayout
Edit
Also, a CollapsingToolbar needs RecyclerView or NestedListView to work.
inside relative layout put this one close after every tag close inside relative layout
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:fillViewport="true"
android:fitsSystemWindows="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:layout_gravity="fill_vertical">

CollapsingToolbarLayout won't collapse

I am having issues with the expected scroll behavior of a collapsing toolbar layout within an app. To ensure I kinda knew what I was doing I created a simple test project and was able to achieve the desired result, but a NestedScrollView was used in that example and the content that required scrolling was just a RelativeLayout containing a CardView with a lot of text. In the real app the scroll content is a RecyclerView, which I assume is the problem. It is as if the RecyclerView is handling the scrolling and the parent CollapsingToolbar is left out of the loop.
Notice that the app:layout_behavior="#string/appbar_scrolling_view_behavior" is not currently in the layout. I have tried adding it to various places without the desired result.
Attached is an image of the app after a small amount of scrolling has been performed with the collapsing toolbar above not reducing it's height.
<?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:context=".ui.ArticleListActivity">
<android.support.design.widget.AppBarLayout
android:id="#+id/toolbar_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/Theme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/theme_primary"
app:contentScrim="#color/theme_primary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:src="#drawable/empty_detail"
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">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/app_name"
android:src="#drawable/logo" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/swipe_refresh_layout"
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/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
</android.support.design.widget.CoordinatorLayout>
According to your code what's missing is that you have to set the scrolling flag "scroll" to the imageview above the Toolbar.
I've done a similar thing and as you can see on the code below, all the views that are meant to react to the RecyclerView Scrolling have the scrolling flag and they are before the views that we don't want to scroll such asthe Toolbar:
<android.support.design.widget.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:id="#+id/collapsingToolbar"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:contentScrim="?attr/colorPrimary"
>
<include layout="#layout/movie_details_header_layout" android:id="#+id/headerLayout"
app:layout_scrollFlags="scroll"
/>
<android.support.v7.widget.Toolbar
android:layout_height="56dp"
android:layout_width="match_parent"
android:id="#+id/toolbar"
app:navigationIcon="#drawable/ic_arrow_back"
android:navigationContentDescription="Back"
app:layout_collapseParallaxMultiplier="0.7"
app:layout_collapseMode="pin"
/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
The project came using version 22.x of the compat libraries, updating to 23 seemed to fix everything.

Collapsing Toolbar. How to adapt custom Layout instead of default ImageView

I want to make collasping toolbar, in which is my custom Layout . On the image below is presented use of new released design.support lib. On the img.1, the element (ImageView) is disappearing. In my project I want to disappear a Layout.
Because inside Layout will be ViewPager it can not be resized like the image, it should dissolve in Toolbar background - should become transparent.
img. 1
Additionaly I want to open/hide ToolbarLayout by moving ToolbarFooter - belt to move - bright blue Layout. So expand/collapse are not like in img.1 Instead it should works like status bar that shifts up and down by blick on ToolbarFooter.
img.2
The think is I read about it a lot (collapsing with button , layout inside) of but I've found any clue or implementation. I don't know how to approach to this topic.
I suppose that my ViewPager and RelativeLayout(or whatever) should be outside of the toolbar. And they should just take a place of toolbar view like this:
<android.support.v4.widget.DrawerLayout
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">
<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"
android:clipChildren="false">
<android.support.v7.widget.Toolbar
android:id="#+id/app_bar"
android:layout_width="match_parent"
android:layout_height="#dimen/app_bar_max_height"
android:minHeight="?attr/actionBarSize"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:theme="#style/AppBarTheme">
<Button
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_alignParentTop="true"
android:layout_gravity="left|top"
android:gravity="center_vertical|left"
android:text="ToolbarTitle"
android:background="?android:attr/selectableItemBackground"
android:textAllCaps="false"/>
</android.support.v7.widget.Toolbar>
<net.android.app.views.ViewPagerToolbar
android:id="#+id/calendar_viewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="?attr/actionBarSize"/>
<RelativeLayout
android:id="#+id/toolbar_footer"
android:layout_width="match_parent"
android:layout_height="#dimen/app_bar_height"
android:layout_alignParentTop="false"
android:layout_alignBottom="#+id/app_bar">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="8dp"
android:text="#string/belt_to_move"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="#string/belt_to_move"/>
</RelativeLayout>
<android.support.v4.widget.DrawerLayout
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/app_bar">
<android.support.v4.view.ViewPager
android:id="#+id/vp_container"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
<android.support.design.widget.NavigationView
android:id="#+id/navView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"/>
Now can anyone tell me what component should I use?
Support library offers CoordinateLayout, CollapsedToolbar, Appbar.
By standard approach can be use RelativeLayout or FrameLayout which overlap view. So guys what you recommend me, how from which side should I eat this cake?
UPDATED:
Finally I've found the solution. It isn't CollapsingToolbar but ViewDragHelper.
The solution I followed: Blog, GitHub project, YouTube explanation,
You need attach a viewPager above toolbar.
Example for ImageView :
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="240dp"
android:fitsSystemWindows="true"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:elevation="2dp">
<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:elevation="2dp"
app:collapsedTitleTextAppearance="?attr/autoCompleteTextViewStyle"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
// put here your content
<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:elevation="2dp"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"/>
</RelativeLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>

Design Support Library, Toolbar buttons cropped ripple

I'm trying to utilize the CoordinatorLayout, AppBarLayout, CollapsingToolbarLayout, Toolbar and a parallax'ed ImageView. It looks like the ripple effect of the toolbar menu items is cropped. The following image displays the ripple effect of the back button in expanded and in partially collapsed mode. In complete collapsed mode the ripple effect is not shown at all. I think this is caused by the parallax'ed ImageView that is positioned there.
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:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
</android.support.v4.view.ViewPager>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="224dp"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:weightSum="1.0">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="56dp"
android:layout_weight="1.0"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="48dp"
android:scaleType="centerInside"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.4"/>
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
</android.support.design.widget.CollapsingToolbarLayout>
<android.support.design.widget.TabLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#color/transparent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:tabGravity="fill"
app:tabMode="fixed"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
The ImageView displays a 9-patch'ed Image. Is there something wrong with the layout or is it a bug/inability in the design support library to draw the ripple ontop of the ImageView?
I think your solution is here.
You can try to add this line:
<item name="actionBarItemBackground">?attr/selectableItemBackground</item>
in the theme/style of your Toolbar.
If it doesn't work, add this in your Toolbar attributes:
android:background="#android:color/transparent"

Categories

Resources