android - FloatingActionButton doesn't hide -


i trying hide floatingactionbutton fablocation programmatically :

fablocation.setvisibility(view.gone) 

but not work.

if add android:visibility="gone" in xml layout, fablocation hidden when run activity reappears when scroll.

here 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:fitssystemwindows="true">  <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="@color/coloroverlay"         app:expandedtitlemarginend="64dp"         app:expandedtitlemarginstart="48dp"         app:layout_scrollflags="scroll|exituntilcollapsed">          <imageview             android:id="@+id/img_couverture"             android:layout_width="match_parent"             android:layout_height="match_parent"             android:fitssystemwindows="true"             android:scaletype="centercrop"             android:src="@drawable/bg_navigation_drawer_header"             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:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical"     app:layout_behavior="@string/appbar_scrolling_view_behavior">      <linearlayout         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:orientation="vertical">          <android.support.v7.widget.cardview             android:layout_margintop="8dp"             android:layout_width="match_parent"             android:layout_height="wrap_content">              <linearlayout                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:orientation="vertical"                 android:padding="16dp">                  <textview                     android:id="@+id/tv_name"                     android:layout_width="match_parent"                     android:layout_height="wrap_content"                     android:textsize="18sp" />                  <view                     android:background="@drawable/separator_orange_gradient"                     android:layout_margintop="8dp"                     android:layout_marginbottom="16dp"                     android:layout_width="match_parent"                     android:layout_height="2dp"/>                  <textview                     android:id="@+id/tv_history"                     android:layout_width="match_parent"                     android:layout_height="wrap_content"                     android:textappearance="@style/textappearance.robotolight" />              </linearlayout>          </android.support.v7.widget.cardview>      </linearlayout>  </android.support.v4.widget.nestedscrollview>  <android.support.design.widget.floatingactionbutton     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_margin="16dp"     android:clickable="true"     android:id="@+id/fab_location"     android:src="@drawable/ic_fab_location_24dp"     app:backgroundtint="@color/colororange"     app:layout_anchor="@id/appbar"     app:layout_anchorgravity="bottom|right|end" /> 

it due app:layout_anchor attribute. must rid of anchor before changing visibility:

coordinatorlayout.layoutparams p = (coordinatorlayout.layoutparams) fab.getlayoutparams(); p.setanchorid(view.no_id); fab.setlayoutparams(p); fab.setvisibility(view.gone); 

Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -