android - Make FloatingActionButton Disappear Behind Toolbar -
so have got floatingactionbutton anchored imageview. when scroll down, want fab hide behind toolbar, not hovering on it.
is there way can achieve this? can't seem work. tried use layout_weight didn't work sadly.
current xml layout:
<android.support.design.widget.appbarlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/apptheme.appbaroverlay"> <android.support.v7.widget.toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionbarsize" android:background="?attr/colorprimary" app:popuptheme="@style/apptheme.popupoverlay" android:layout_weight="1000" /> </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" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" > <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <imageview android:id="@+id/channelbanner" android:layout_width="match_parent" android:layout_height="wrap_content" android:src="@drawable/default_banner" android:adjustviewbounds="true" android:scaletype="fitcenter" /> <gridlayout android:layout_width="match_parent" android:alignmentmode="alignbounds" android:layout_height="match_parent" android:layout_centerhorizontal="true" android:rowcount="6" android:columncount="2" android:padding="6dp" android:id="@+id/channelcontent"> <android.support.v7.widget.cardview xmlns:card_view="http://schemas.android.com/apk/res-auto" android:layout_gravity="center" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margintop="8dp" card_view:cardcornerradius="2dp" card_view:contentpadding="10dp" android:layout_row="0" android:layout_column="0" android:layout_columnspan="2"> <linearlayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> <relativelayout android:layout_width="100dp" android:layout_height="100dp"> <com.makeramen.roundedimageview.roundedimageview android:layout_width="100dp" android:layout_height="100dp" android:id="@+id/avatarview" android:src="@drawable/youtube_default_avatar" app:riv_corner_radius="30dip" app:riv_border_width="1dip" app:riv_border_color="#212121" app:riv_mutate_background="true" app:riv_tile_mode="repeat" app:riv_oval="true" android:layout_weight="1"/> </relativelayout> <linearlayout android:orientation="vertical" android:layout_width="match_parent" android:gravity="right" android:layout_gravity="right" android:id="@+id/subscriberlayout" android:layout_height="wrap_content" android:layout_weight="3"> <it.bjarn.android.subscribercount.customviews.autoresizetextview android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margintop="12dp" android:ellipsize="none" android:maxlines="1" android:gravity="right" android:layout_gravity="right" android:text="0" android:textsize="48sp" android:textcolor="@color/primarytext" android:id="@+id/subscribercount" android:textstyle="bold" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancesmall" android:gravity="right" android:layout_gravity="right" android:text="subscribers" android:id="@+id/subscribertext" /> </linearlayout> </linearlayout> </android.support.v7.widget.cardview> <android.support.v7.widget.cardview xmlns:card_view="http://schemas.android.com/apk/res-auto" android:layout_gravity="center" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="5dp" card_view:cardcornerradius="2dp" card_view:contentpadding="10dp" android:layout_margintop="8dp" android:layout_row="1" android:layout_column="0" android:layout_columnspan="2"> <linearlayout android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="left" android:id="@+id/descriptionlayout"> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancesmall" android:text="description" android:id="@+id/descriptiontitle" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancelarge" android:text="..." android:id="@+id/descriptioncontent" android:ellipsize="end" android:singleline="true" android:clickable="true" android:onclick="onclick" android:textstyle="italic" /> </linearlayout> </android.support.v7.widget.cardview> <android.support.v7.widget.cardview xmlns:card_view="http://schemas.android.com/apk/res-auto" android:layout_gravity="center" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="5dp" card_view:cardcornerradius="2dp" card_view:contentpadding="10dp" android:layout_margintop="8dp" android:layout_row="2" android:layout_column="0" android:layout_columnspan="2"> <linearlayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:id="@+id/subscriberoldlayout"> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancelarge" android:text="0" android:id="@+id/subscriberoldcount"/> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancesmall" android:text="subscribers shown youtube" android:id="@+id/subscriberoldtext" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancelarge" android:text="0" android:id="@+id/viewscount"/> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancesmall" android:text="views" android:id="@+id/viewstext" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancelarge" android:text="0" android:id="@+id/videoscount"/> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancesmall" android:text="videos" android:id="@+id/videostext" /> </linearlayout> </android.support.v7.widget.cardview> </gridlayout> </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_margin" android:src="@drawable/ic_star_grey_400_24dp" app:layout_anchor="@id/channelbanner" app:layout_anchorgravity="bottom|end" app:backgroundtint="@color/youtubeaccent" android:clickable="true" android:layout_weight="999" />
Comments
Post a Comment