原因见 http://www.jianshu.com/p/38af0cf77352 (坑2)
在 https://code.google.com/p/android/issues/detail?id=201793 找到的答案,用ExpandedBottomSheetDialog替代BottomSheetDialog即可。
public class ExpandedBottomSheetDialog extends BottomSheetDialog {
public ExpandedBottomSheetDialog(@NonNull Context context) {
super(context);
}
protected ExpandedBottomSheetDialog(@NonNull Context context, boolean cancelable, OnCancelListener cancelListener) {
super(context, cancelable, cancelListener);
}
public ExpandedBottomSheetDialog(@NonNull Context context, @StyleRes int theme) {
super(context, theme);
}
@Override
public void show() {
super.show();
final View view = findViewById(R.id.design_bottom_sheet);
view.post(new Runnable() {
@Override
public void run() {
BottomSheetBehavior behavior = BottomSheetBehavior.from(view);
behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
});
}
}
网友评论