最近android.support.design.widget.BottomSheetDialogFragmentを使用しました。私はGoogleの連絡先アプリに似た何かをしたかったので、BottomSheetはツールバーとステータスバーの上に重ねることができます。あなたはアクティビティのツールバーがまだ表示されて見ることができるように bottomSheetDialogをステータスバーの全画面に表示
:私はこれを実装するためにBottomSheetDialogFragmentを使用する場合しかし、それはこれに判明します。ここBottomSheetDialogFragment
の私のコードは次のとおりです。
public class KeyDetailFragment extends BottomSheetDialogFragment {
private BottomSheetBehavior.BottomSheetCallback mBottomSheetBehaviorCallback = new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
if (newState == BottomSheetBehavior.STATE_HIDDEN) {
dismiss();
}
}
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
}
};
@Override
public void setupDialog(Dialog dialog, int style) {
super.setupDialog(dialog, style);
View contentView = View.inflate(getActivity(), R.layout.sheet_key, null);
dialog.setContentView(contentView);
View parent = (View) contentView.getParent();
parent.setFitsSystemWindows(true);
BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(parent);
contentView.measure(0, 0);
bottomSheetBehavior.setPeekHeight(contentView.getMeasuredHeight());
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) parent.getLayoutParams();
if (params.getBehavior() instanceof BottomSheetBehavior) {
((BottomSheetBehavior)params.getBehavior()).setBottomSheetCallback(mBottomSheetBehaviorCallback);
}
params.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
parent.setLayoutParams(params);
}
}
私はソースと呼ばれ、私は属性が私を興味が見つかりました:
private static int getThemeResId(Context context, int themeId) {
if (themeId == 0) {
// If the provided theme is 0, then retrieve the dialogTheme from our theme
TypedValue outValue = new TypedValue();
if (context.getTheme().resolveAttribute(
R.attr.bottomSheetDialogTheme, outValue, true)) {
themeId = outValue.resourceId;
} else {
// bottomSheetDialogTheme is not provided; we default to our light theme
themeId = R.style.Theme_Design_Light_BottomSheetDialog;
}
}
return themeId;
}
ここ属性bottomSheetDialogTheme
がボトムシートのスタイルを変更することがありますが、私はしないでくださいそれを変更する方法を知っていて、これが機能するかどうかは疑問です。誰かがツールバーとステータスバーをオーバーレイすることができるということについて私に解決策を教えてもらえますか?
同じ問題は、これに対する解決策を見つけましたか? –
@ nipun.birlaいいえ、まだ3ヶ月経っていますが、まだ見つかりませんでした –
私は理由が仰角だと思います。これを確認してください:http://stackoverflow.com/questions/35711808/android-bottomsheet-is-hinding-under-the-toolbar –