android - BottomSheet fly away with visibility change -


i have bottom sheet nestedscrollview inside (see below). when press on fab button, want make parts in nestedscrollview invisible. when change linearlayouts visibilities gone, bottomsheet fly aways top. see here:

enter image description here

you can whole code https://github.com/tanrikut/bottomsheetexample

my change visibility method:

private void changevisibility() {     subtitlelayout.setvisibility(view.gone);      coordinatelayout.setvisibility(view.gone);     timelayout.setvisibility(view.gone);  } 

my nestedscrollview xml:

<?xml version="1.0" encoding="utf-8"?> <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="wrap_content"     app:behavior_peekheight="120dp"     app:layout_behavior="android.support.design.widget.bottomsheetbehavior"     android:id="@+id/bottom_sheet_main">      <framelayout         android:layout_width="match_parent"         android:layout_height="wrap_content">          <linearlayout             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:layout_margintop="28dp"             android:background="@android:color/white"             android:animatelayoutchanges="true"             android:orientation="vertical"             >              <linearlayout                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:orientation="vertical"                 android:paddingleft="10dp"                 android:paddingstart="10dp"                 android:paddingtop="@dimen/activity_horizontal_margin">                  <textview                     style="@style/textappearance.appcompat.headline"                     android:layout_width="match_parent"                     android:layout_height="wrap_content"                     android:text="dandelion chocolate"                     android:id="@+id/title" />                 <linearlayout                     android:layout_width="match_parent"                     android:layout_height="wrap_content"                     android:layout_marginbottom="@dimen/activity_horizontal_margin"                     android:layout_margintop="16dp"                     android:orientation="horizontal"                     android:id="@+id/subtitlelayout">                      <textview                         android:layout_width="match_parent"                         android:layout_height="wrap_content"                         android:id="@+id/subtitle"                         android:text="subtitle" />                  </linearlayout>               </linearlayout>               <linearlayout                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:orientation="horizontal"                 android:padding="@dimen/activity_horizontal_margin"                 android:id="@+id/coordinatelayout">                  <imagebutton                     android:layout_width="24dp"                     android:layout_height="24dp"                     android:alpha="0.36"                     android:src="@drawable/ic_room_24dp"                     android:background="@null" />                  <textview                     android:layout_width="match_parent"                     android:layout_height="wrap_content"                     android:layout_marginleft="@dimen/activity_horizontal_margin"                     android:layout_marginstart="@dimen/activity_horizontal_margin"                     android:text="740, valencia st, san francisco, ca"                     android:textcolor="@android:color/primary_text_light"                     android:id="@+id/bottom_sheet_coordinate" />              </linearlayout>              <linearlayout                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:orientation="horizontal"                 android:padding="@dimen/activity_horizontal_margin"                 android:id="@+id/timelayout">                  <imagebutton                     android:layout_width="24dp"                     android:layout_height="24dp"                     android:alpha="0.36"                     android:src="@drawable/ic_query_builder_24dp"                     android:background="@null" />                  <textview                     android:layout_width="match_parent"                     android:layout_height="wrap_content"                     android:layout_marginleft="@dimen/activity_horizontal_margin"                     android:layout_marginstart="@dimen/activity_horizontal_margin"                     android:text="wed, 10 - 9 pm"                     android:textcolor="@android:color/primary_text_light"                     android:id="@+id/bottom_sheet_time" />              </linearlayout>           </linearlayout>      </framelayout> </android.support.v4.widget.nestedscrollview> 

i ran this, took while figure out cause.

it's because you're using android:animatelayoutchanges, surfaces bug in either bottomsheetbehavior or coordinatorlayout.

remove , bottomsheet stop animating on own when shouldn't. not fix, workaround @ least.

--

update:

turns out if enable "animatelayoutchanges" programmatically setting layouttransition instance use, can set flag on prevent messing views ancestors of 1 you're using android:animatelayoutchanges on (aka: bottomsheet container):

layouttransition transition = new layouttransition(); transition.setanimateparenthierarchy(false); yourlinearlayoutthatneedslayoutanimation.setlayouttransition(transition); 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -