Obsolete
Status Update
Comments
sa...@gmail.com <sa...@gmail.com> #2
note "./gradlew clean assembleqaDebug" works fine
pa...@google.com <pa...@google.com>
ya...@google.com <ya...@google.com> #4
Thanks for the feedback. We believe that this issue has been resolved in newer versions of the product. Please try it out and if you still experience issues with it, do not hesitate to file a new bug.
For information of what’s needed in the report please don’t forget to read this guide athttps://developer.android.com/studio/report-bugs
For information of what’s needed in the report please don’t forget to read this guide at
[Deleted User] <[Deleted User]> #5
When should we call BottomSheetBehavior#setState(STATE_EXPANDED) ?
My every attempt of calling setState (in various dialog lifecycle states) ended up with NullPointerException.
Could You please write explicitly when should be call setState?
My every attempt of calling setState (in various dialog lifecycle states) ended up with NullPointerException.
Could You please write explicitly when should be call setState?
cj...@gmail.com <cj...@gmail.com> #6
"Note that you cannot call the method before view layouts." <---
In onCreateDialog() of the modal bottom sheet, just before returning the dialog (or anywhere, once you have a reference to it), call:
// This listener's onShow is fired when the dialog is shown
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
// In a previous life I used this method to get handles to the positive and negative buttons
// of a dialog in order to change their Typeface. Good ol' days.
BottomSheetDialog d = (BottomSheetDialog) dialog;
FrameLayout bottomSheet = (FrameLayout) d.findViewById(android.support.design.R.id.design_bottom_sheet);
// Right here!
BottomSheetBehavior.from(bottomSheet).setState(BottomSheetBehavior.STATE_EXPANDED);
}
});
In onCreateDialog() of the modal bottom sheet, just before returning the dialog (or anywhere, once you have a reference to it), call:
// This listener's onShow is fired when the dialog is shown
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
// In a previous life I used this method to get handles to the positive and negative buttons
// of a dialog in order to change their Typeface. Good ol' days.
BottomSheetDialog d = (BottomSheetDialog) dialog;
FrameLayout bottomSheet = (FrameLayout) d.findViewById(android.support.design.R.id.design_bottom_sheet);
// Right here!
BottomSheetBehavior.from(bottomSheet).setState(BottomSheetBehavior.STATE_EXPANDED);
}
});
[Deleted User] <[Deleted User]> #7
Solution from previous post is working. Thanks very much for sharing it :)
ma...@gmail.com <ma...@gmail.com> #8
Solution #7 has some issues, probably with v 23.2.1? If I use it, all calls to view.findViewById(...) in onViewCreated do return null.
ty...@gmail.com <ty...@gmail.com> #9
I believe I have run into a similar issue, although not exactly the same. I believe this belongs on the same ticket though. In my case, I was using a BottomSheet to hold a fragment that can be expanded or collapsed. When the BottomSheet is in a collapsed state, and setState(BottomSheetBehavior.STATE_EXPANDED) is requested with a new fragment transaction for the bottom sheet, the new fragment wasn't showing up.
https://github.com/tylerjroach/BottomSheetBug
After reading this, I came across:
"Note that you cannot call the method before view layouts."
I was able to fix my specific issue with the code below.
rootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
rootView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
((MainActivity)getActivity()).expandBottomSheet();
}
});
The note about waiting for the view to layout should really be added to the documentation if it isn't currently listed.
After reading this, I came across:
"Note that you cannot call the method before view layouts."
I was able to fix my specific issue with the code below.
rootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
rootView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
((MainActivity)getActivity()).expandBottomSheet();
}
});
The note about waiting for the view to layout should really be added to the documentation if it isn't currently listed.
at...@gmail.com <at...@gmail.com> #10
I have some case when I cant show bottom sheet via invocation of show() after this was closed by swipe.
my variant of fix:
// kotlin
setContentView(contentView, ViewGroup.LayoutParams(...))
// fix close-by-swipe
(contentView.parent as? FrameLayout)?.let {
// disable swipe on contentView
BottomSheetBehavior.from(it).isHideable = false
}
my variant of fix:
// kotlin
setContentView(contentView, ViewGroup.LayoutParams(...))
// fix close-by-swipe
(contentView.parent as? FrameLayout)?.let {
// disable swipe on contentView
BottomSheetBehavior.from(it).isHideable = false
}
Description
Version used: 23.2.0
Theme used: Theme.AppCompat.Light.NoActionBar
Devices/Android versions reproduced on: Android API 23, 21 and 15 (x86 emulator)
BottomSheetDialogFragment isn't shown expanded when BottomSheetDialog.show() method is called. In order to reproduce this bug, check out
That code is an example for persistent and modal bottom sheets. It includes an activity with three buttons to expand, collapse and hide a persistent bottom sheet and a fourth button to show a modal bottom sheet. If you test it, you will find that the modal bottom sheet does not show expanded when the corresponding button is pressed.
I have attached a zip including the code linked before just in case it gets changed by another commit. And I've also attached a video showing the issue.