android - Collapsing toolbar animation doesn't move -
i implementing collapse toolbar in app , should right bar not restricted .. not move nothing !!!
this layout.xml
<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/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_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/background" 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.design.widget.floatingactionbutton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="@dimen/fab_button_margin_right" android:clickable="true" android:src="@drawable/fab_ic_add" app:layout_anchor="@+id/appbar" app:layout_anchorgravity="bottom|right|end" /> </android.support.design.widget.coordinatorlayout>
and activity
public class profile extends appcompatactivity implements view.onclicklistener{ private toolbar toolbar; private collapsingtoolbarlayout collapsingtoolbar; int mutedcolor = r.attr.colorprimary; floatingactionbutton fab; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.profile); final toolbar toolbar = (toolbar) findviewbyid(r.id.anim_toolbar); setsupportactionbar(toolbar); getsupportactionbar().setdisplayhomeasupenabled(true); collapsingtoolbar = (collapsingtoolbarlayout) findviewbyid(r.id.collapsing_toolbar); collapsingtoolbar.settitle("hello!"); imageview header = (imageview) findviewbyid(r.id.header); bitmap bitmap = bitmapfactory.decoderesource(getresources(), r.drawable.background); fab = (floatingactionbutton) findviewbyid(r.id.fab); if(fab != null) fab.setonclicklistener(this); palette.from(bitmap).generate(new palette.paletteasynclistener() { @override public void ongenerated(palette palette) { mutedcolor = palette.getmutedcolor(r.attr.colorprimary); collapsingtoolbar.setcontentscrimcolor(mutedcolor); } }); } }
please tell me why , in advance!
update: i've solved problem nestedscrollview, this:
<?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" xmlns:card="http://schemas.android.com/tools" android:id="@+id/rootlayout" android:fitssystemwindows="true"> <android.support.design.widget.appbarlayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="380dp" android:theme="@style/themeoverlay.appcompat.dark.actionbar" android:fitssystemwindows="true"> <android.support.design.widget.collapsingtoolbarlayout android:id="@+id/collapsingtoolbarlayout" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_scrollflags="scroll|exituntilcollapsed" app:expandedtitlemarginstart="48dp" app:expandedtitlemarginend="64dp" android:fitssystemwindows="true"> <imageview android:id="@+id/header" android:src="@drawable/background" android:layout_width="match_parent" android:layout_height="match_parent" android:scaletype="centercrop" android:fitssystemwindows="true" app:layout_collapsemode="parallax"/> <android.support.v7.widget.toolbar android:id="@+id/toolbaraction" 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> <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"> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <!-- list of --> </linearlayout> </android.support.v4.widget.nestedscrollview> <android.support.design.widget.floatingactionbutton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="@dimen/fab_button_margin_right" android:clickable="true" android:src="@drawable/user" app:backgroundtint="@color/testprimarydark" app:layout_anchor="@+id/appbar" app:layout_anchorgravity="bottom|right|end" /> </android.support.design.widget.coordinatorlayout>
check works me, can add view inside appbarlayout under toolbar animate , down toolbar
<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/coordinatelayout" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.appbarlayout android:id="@+id/appbarlayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/themeoverlay.appcompat.dark.actionbar"> <android.support.v7.widget.toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionbarsize" android:background="?attr/colorprimary" app:layout_scrollflags="scroll|enteralways" app:popuptheme="@style/themeoverlay.appcompat.light" /> </android.support.design.widget.appbarlayout> <android.support.v4.view.viewpager android:id="@+id/tabanim_viewpager" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> </android.support.design.widget.coordinatorlayout>
you can change viewpager view add behavior, can check bartosz lipinski answer if want animate programmatically link
Comments
Post a Comment