I used Android support design library to build a profile view for an app I'm working on.
The profile is composed of a header with a header picture as the background and a rounded profile picture on the center. Besides, there ir a small view on the bottom corner of the header.
Below the header is a viewpager with a tablayout.
The problem I'm facing is that there are inconsistencies between Android 5.1.1 and 5.0.2 and below.
Here's how the profile is shown on a Nexus 5 with 5.1.1 Android:
And here's how the profile is shown on a Xperia Z2 with 5.0.2 Android:
Here's the code:
<FrameLayout
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:background="#color/white">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_height="250dp"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/profile_collapsingtoolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="#+id/profile_header"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"
app:layout_scrollFlags="scroll|enterAlways"/>
<com.makeramen.roundedimageview.RoundedImageView
android:id="#+id/profile_image"
android:layout_width="90dp"
android:layout_height="90dp"
app:riv_corner_radius="45dp"
app:riv_border_color="#color/red"
app:riv_border_width="1dp"
android:layout_gravity="center"
app:layout_collapseMode="none"
app:layout_scrollFlags="scroll|enterAlways" />
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:layout_margin="5dp"
android:layout_gravity="bottom|right"
android:background="#drawable/shape_usertype_background">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
android:textColor="#color/white"
android:text="Professional"/>
</FrameLayout>
<android.support.v7.widget.Toolbar
android:id="#+id/profile_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/profile_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:paddingTop="45dp"/>
<android.support.design.widget.TabLayout
android:id="#+id/profile_tablayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
app:tabGravity="center"
app:tabMode="scrollable"
app:tabIndicatorColor="#color/red"
app:tabTextColor="#color/main_dark"
app:tabSelectedTextColor="#color/red"
android:fitsSystemWindows="true"
app:layout_anchor="#id/appbar"
app:layout_anchorGravity="bottom"
android:background="#color/white"
/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/profile_floatingbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:clickable="true"
android:src="#android:drawable/ic_menu_share"
app:backgroundTint="#color/red"
app:layout_anchor="#id/profile_pager"
app:layout_anchorGravity="bottom|right|end"
app:rippleColor="#android:color/darker_gray"
app:borderWidth="0dp"/>
</android.support.design.widget.CoordinatorLayout>
</FrameLayout>
So, anyone has an idea on how to fix this?
Thanks!
Design Library is unfortunately quite buggy and it should be considered "beta" rather than production ready. It looks and behaves differently depending on Android version your app is running on and problems I spotted are not only related to CoordinatorLayout, but even relatively simple widget like TextInputLayout is not working the same way everywhere. Knowing design library is quite fresh product, I am not sure it is worth spending your own time working around (not fixing) Google bugs. I'd just wait for next iteration of the library, expecting improvements and bug fixes.
Related
I have provided the screenshot of my app screen. You can see that the floating button ( in this case i used Image Button and provided my image) is not showing full i.e. its half part is behind the app bar, the app bar is in green color. Although this same FAB button is showing full in some devices and versions like 4.2, 4.3 but not showing full on some devices and my version 5.0 and up.
Following is my code for this 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/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar"
android:layout_width="match_parent"
android:layout_height="190dp"
android:fitsSystemWindows="true"
android:background="#drawable/cvr1"
app:expanded="true">
<!--android:theme="?attr/customAppBarOverlay"-->
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="snap">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
android:background="#null"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_main" />
<ImageButton
android:id="#+id/add_fab"
android:background="#drawable/starts"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_margin="#dimen/fab_margin"
app:layout_anchor="#id/app_bar"
app:elevation="0dp"
app:layout_anchorGravity="bottom|center"
/>
</android.support.design.widget.CoordinatorLayout>
I dont know what exactly is the issue. I checked on internet but found same solutions like these lines but still not showing full
app:layout_anchor="#id/app_bar"
app:layout_anchorGravity="bottom|center"
Please Help!
The best practice is to use the F A B (Floating Action Bar) provided in the support library.
Add this to build.gradle file:
compile 'com.android.support:design:24.2.1'
And inside the CoordinatorLayout try 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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="#+id/viewA"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.4"
android:background="#android:color/holo_purple"
android:orientation="horizontal"/>
<LinearLayout
android:id="#+id/viewB"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.6"
android:background="#android:color/holo_orange_light"
android:orientation="horizontal"/>
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:clickable="true"
android:src="#drawable/ic_done"
app:layout_anchor="#id/viewA"
app:layout_anchorGravity="bottom|right|end"/>
This should produce the FAB as provided in the below image:
In order to change the position of the FAB , you can change:
app:layout_anchorGravity="bottom|right|end"/>
to the preferred way for the ideal position in your layout.
The reason for this is you are using app:elevation="0dp" on your button. As the AppBarLayout has default elevation of 4dp, on lollipop devices and higher, the button will be drawn under it.
I am using collapsable layout . Here is the main layout for that,
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout android:id="#+id/main_content"
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:fitsSystemWindows="true"
tools:context=".MainActivity">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<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">
<ImageView
android:id="#+id/bgheader"
android:layout_width="match_parent"
android:layout_height="300dp"
android:scaleType="centerCrop"
android:fitsSystemWindows="true"
android:background="#drawable/scenary"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:attrs="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="#style/AppTheme.PopupOverlay">
<FrameLayout
android:id="#+id/titleContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center">
<.utils.CustomFontTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Toolbar Title"
android:textColor="#ffffff"
attrs:customFont="handyman_bold"
android:textSize="8pt"
android:layout_marginLeft="-20dp"
android:id="#+id/toolbar_title"/>
</FrameLayout>
<ImageButton
android:id="#+id/btn_ToolBarRightBtn"
android:layout_width="32dp"
android:layout_height="28dp"
android:tag="0"
android:background="#null"
android:scaleType="fitXY"
android:src="#drawable/icon_shopping"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:layout_marginRight="10dp"
/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"/>
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
android:layout_gravity="bottom"
android:background="#color/offwhite"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.design.widget.CoordinatorLayout>
Inside the ViewPager I have a recycler view. Here is what I see when I load the app ,
When I scroll up the recycler view I am seeing this,
I am not sure why I see the gap initially and later it is getting filled with the app primary color. What a I doing here?
Attached animated gif of my screen.
Thanks
One straightforward solution is to use design support library version 23.1.1 This issue happens for design support library 23.2.0 onwards.
compile 'com.android.support:design:23.1.1'
Second solution is removing the line android:fitsSystemWindows="true" from the CoordinatorLayout.
UPDATE :
in both case the toolbar is overlapping the image, so the portion under status bar is not visible
This is happening because CollapsingToolbarLayout class is a child of FrameLayout. So the views you pass in the framelayout will stack upon each other. that's why toolbar is overlapping the image. The simplest solution in your case I found is to put android:layout_marginTop="?attr/actionBarSize" in the ImageView.
There is no app:layout_behavior="#string/appbar_scrolling_view_behavior"in your FrameLayout
<FrameLayout
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:id="#+id/titleContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
I would like to achieve something similar to the following in my app, but I want the whole red area (where it says "Guardians Of The Gala..." in the screenshots below) to be a custom view. (Some elements would fade out as the toolbar is collapsed.)
``
`
I've been trying for hours and hours to get it to work, but to no avail.
Obviously, just putting it into <Toolbar> doesn't work, since it doesn't know that it's supposed to animate it:
<android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.AppBarLayout>
<android.support.design.widget.CollapsingToolbarLayout>
<ImageView/>
<android.support.v7.widget.Toolbar>
<include layout="#layout/link_view_title_bar"/>
I've tried doing most of the answers from here and here but nothing actually worked.
How could I do this, preferably using mostly XML and the Android Design Support library. Any help would be appreaciated.
<android.support.design.widget.CoordinatorLayout
android:id="#+id/homeCoordinator"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="#+id/homeAppBarLayout"
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/homeCollapseToolbar"
android:layout_width="match_parent"
android:layout_height="350dp"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
//This can be changed to ImageView
<com.daimajia.slider.library.SliderLayout
android:id="#+id/homeSliderLayout"
app:layout_collapseMode="parallax"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="350dp"/>
<android.support.v7.widget.Toolbar
android:id="#+id/homeToolbar"
android:title=""
android:layout_width="match_parent"
android:layout_height="115dp"
android:gravity="top"
android:minHeight="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:titleMarginTop="15dp" >
<ImageView
android:src="#drawable/ic_logo"
android:paddingLeft="10dp"
android:layout_gravity="center|top"
android:layout_width="wrap_content"
android:layout_height="35dp" />
</android.support.v7.widget.Toolbar>
//Instead of the TabLayout, put your Red Layout
<android.support.design.widget.TabLayout
android:id="#+id/homeTabLayout"
android:layout_marginBottom="15dp"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="bottom"
app:tabGravity="center"
app:tabIndicatorColor="#color/colorAccent" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/homeViewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
I want to implement a collapsing toolbar like google Play Store. I have achieved functionality somewhat but that is only working for portrait Screen. Here is a sample of screenshot of what i was able to do.
Now what i want to do is when i change my device orientation to LandScape mode it should look Exactly Like This.
So what my main question is how to handle these orientation changes. Is there any official android component available that can do this kind of thing or I will have to Z-index my Layouts to achieve this kind of Layout behavior. Please note that I want the layout to be exactly like this with Margins on Both Sides and Z-indexing on top of picture also the scrolling behavior needs to be exactly like Google Play Store.
I am attaching my sample xml that I have written so far.
<?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:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar_layout"
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="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<com.group3amd.materializeyourapp.widgets.SquareImageView
android:id="#+id/image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="#+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
app:cardElevation="#dimen/spacing_medium"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/spacing_large"
android:layout_marginRight="#dimen/spacing_large"
android:layout_marginTop="#dimen/spacing_large"
android:textAppearance="#style/TextAppearance.AppCompat.Headline" />
<TextView
android:id="#+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/spacing_large"
android:text="#string/lorem_ipsum"
android:textAppearance="#style/TextAppearance.AppCompat.Body1" />
</LinearLayout>
</android.support.v7.widget.CardView>
</FrameLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
style="#style/FabStyle"
app:layout_anchor="#id/app_bar_layout"
app:layout_anchorGravity="bottom|right|end" />
</android.support.design.widget.CoordinatorLayout>
In this pretty similar issue: collapsing toolbar layout like google play store, you would find an answer as below:
View inside CollapsingToolbarLayout no need to set
app:layout_scrollFlags. No effect. Base on my code, change
app:layout_scrollFlags in CollapsingToolbarLayout to
app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed" and
set minHeight for it.
As your toolbar is "pin", so enterAlwaysCollapsed will call it when
you scroll down.
<android.support.design.widget.CoordinatorLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true">
<android.support.design.widget.AppBarLayout
android:id="#+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/seffafCollapsingToolbarLayout"
android:layout_width="match_parent"
android:layout_height="240dp"
android:minHeight="?attr/actionBarSize"
app:expandedTitleMarginEnd="164dp"
app:expandedTitleMarginStart="148dp"
app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed">
<ImageView
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/haber_icerik_resim"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="#+id/haber_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:theme="#style/ToolbarColoredBackArrow"
app:layout_collapseMode="pin"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/newsRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:clickable="true"
android:background="#color/mainBackground"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
In the comment to that post, you would find also a hint:
add app:contentScrim="?attr/colorPrimary" to your
collapsingtoolbarlayout. It is no need two toolbars to implement this
effect
EDIT: Here you would find an interview with a guy responsible for Google Play Store, he's talking about how he build design in Play Store App:
[UDACITY] Interview with Kirill Grouchnikov, part 1
[UDACITY] Interview with Kirill Grouchnikov, part 2
Hope it help
I'm struggling with strange behaviour of margin with FloatingActionButton in CoordinatorLayout. FAB adds extra margin which disappears after certain actions.
I followed Cheesesquare example to create detail view. I have exactly the xml same structure. The only difference is that I'm using this view for a fragment instead of raw activity.
This occurs most of the times but sometimes it doesn't. Occurs only once for fragment object, once it fixes itself it works well. On my second phone it doesn't occur. After removing FAB it's ok. When I change sth in calendar, it also causes margin to fix itself.
Attaching gif with layout lines enabled so you can see the margins.
For reference:
<android.support.design.widget.CoordinatorLayout
android:id="#+id/main_content2"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:fitsSystemWindows="true"
tools:context="com.habitsteacher.android.view.fragment.show.ShowHabitFragment">
<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/collapsingToolbarLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginBottom="72dp"
app:expandedTitleMarginEnd="24dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<TextView
android:id="#+id/intentionText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="16dp"
android:layout_marginEnd="24dp"
android:layout_marginLeft="48dp"
android:layout_marginRight="24dp"
android:layout_marginStart="48dp"
android:ellipsize="end"
android:fitsSystemWindows="true"
android:maxLines="2"
android:textColor="#color/icons"
android:textSize="#dimen/abc_text_size_subhead_material"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.25"/>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar_show_habit"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
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.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:id="#+id/habit_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/background_light"
android:orientation="vertical"
android:paddingTop="32dp">
<android.support.v7.widget.CardView
android:id="#+id/calendarWrapper"
android:layout_width="match_parent"
android:layout_height="343dp"
android:layout_margin="#dimen/card_margin">
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:id="#+id/floating_button_edit_habit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:clickable="true"
android:src="#drawable/ic_mode_edit_white_24dp"
app:layout_anchor="#id/appbar"
app:layout_anchorGravity="bottom|right|end"/>
</android.support.design.widget.CoordinatorLayout>
Any thought what could be the reason, or how to investigate this deeper?
It looks like CoordinatorLayout doesn't work properly inside a fragment which is added as non-first to the activity. This looks like a bug in SDK but I couldn't locate the root cause precisely.
As it works properly only when the layout is located on the first added fragment to the activity, I moved fragment with this layout to separate activity and is works properly now.
Still, it's avoiding this behaviour not fixing it so any answer is still appreciated.