CustomBottomSheetBehavior icon indicating copy to clipboard operation
CustomBottomSheetBehavior copied to clipboard

Viewpageer behavior wrong when set state is STATE_HIDDEN

Open ThuyKhanh opened this issue 7 years ago • 4 comments

I want to hide bottom sheet when activity create, so I set state as STATE_HIDDEN in onCreate() function CoordinatorLayout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinatorlayout); View bottomSheet = coordinatorLayout.findViewById(R.id.bottom_sheet); behavior = BottomSheetBehaviorGoogleMapsLike.from(bottomSheet); behavior.setState(BottomSheetBehaviorGoogleMapsLike.STATE_HIDDEN); But I got the this issue. Check out image : https://goo.gl/M8bKpk When I set state as STATE_COLLAPSED onCreate() funtion, it works fine.

ThuyKhanh avatar Apr 11 '17 14:04 ThuyKhanh

https://goo.gl/M8bKpk

Error 403

lordmegamax avatar Apr 13 '17 12:04 lordmegamax

I confirm. When behavior initialized as STATE_HIDDEN in onCreate() something wrong. When I set the state as STATE_COLLAPSED, when the button click, the FAB does not show I logged ScrollAwareFABBehavior.onDependentViewChanged() and see onDependentViewChanged child.getY()=24905.0 DyFix=0 offset=112.0 The value child.getY() is not correct and is constantly increasing

krawa avatar May 15 '17 10:05 krawa

When view hide, actually view is gone. So it loses its correct position. Fix code.

ScrollAwareFABBehavior.onDependentViewChanged()

if ((child.getY() + DyFix) > collapsedY) child.setVisibility(View.INVISIBLE); else if(child.isShown()) child.setVisibility(View.VISIBLE); else child.Show();

leeyc09 avatar May 18 '17 13:05 leeyc09

I can confirm the above fix works.

Thanks @leeyc09 Would you mind creating a merge request to close this issue for others?

vojtisek-michal avatar Aug 14 '17 19:08 vojtisek-michal