相关疑难解决方法(0)

在状态栏上全屏显示bottomSheetDialog

我最近使用了android.support.design.widget.BottomSheetDialogFragment.我想做一些类似于谷歌联系人应用程序的东西,它的BottomSheet可以覆盖工具栏和状态栏.但是,当我使用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(); …
Run Code Online (Sandbox Code Playgroud)

android android-dialogfragment bottom-sheet

12
推荐指数
2
解决办法
2万
查看次数

显示Alert Dialog Android时隐藏状态栏

我正在创建一个应用程序,当您按下某个按钮时会弹出一个警告对话框.状态栏需要隐藏,所以我的活动中有一个方法:

private void hideStatusBar(){
    if (Build.VERSION.SDK_INT < 16){
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }
    else {
        View decorView = getWindow().getDecorView();
        int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
        decorView.setSystemUiVisibility(uiOptions);
    }
}
Run Code Online (Sandbox Code Playgroud)

我在activity的onCreate方法中调用此方法,并且它会正常工作,直到弹出警告对话框.显示警告对话框后,状态栏将立即返回.我尝试了以下方法:

alertDialog.show();
hideStatusBar();
Run Code Online (Sandbox Code Playgroud)

哪个没用.然后我为我的活动覆盖了onWindowFocusChanged方法:

public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    hideStatusBar();
}
Run Code Online (Sandbox Code Playgroud)

这使状态栏的背景透明,但仍然不隐藏它.有没有办法在显示警告对话框时隐藏状态栏?

android statusbar android-alertdialog

10
推荐指数
3
解决办法
8234
查看次数

BottomSheetDialogFragment在横向模式下不显示完整高度

我在我的活动中使用BottomSheetDialogFragment,对话框在纵向模式下显示全高,但在切换到横向模式时不显示.

肖像模式

景观模式

MainActivity.java

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        CustomBottomSheetDialog customBottomSheetDialog = new CustomBottomSheetDialog();
        customBottomSheetDialog.show(getSupportFragmentManager(),customBottomSheetDialog.getTag());
    }
}
Run Code Online (Sandbox Code Playgroud)

CustomBottomSheetDialog

public class CustomBottomSheetDialog extends BottomSheetDialogFragment {

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return View.inflate(getContext(), R.layout.view_config, null);
    }
}
Run Code Online (Sandbox Code Playgroud)

CustomBottomSheetDialog布局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:background="#fdf107"
              android:layout_height="wrap_content">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="196dp"
        android:gravity="center"
        android:textColor="@color/colorAccent"
        android:text="BottomSheetDialogFragment"/>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

在横向模式下,我必须拖动BottomSheetDialogFragment才能看到整个内容.

android

10
推荐指数
5
解决办法
6951
查看次数

如何让BottomSheetDialog全屏显示?

我有这个简单的 BottomSheetDialog,我想将其全屏显示:

class RegistrationDialog : BottomSheetDialogFragment() {


    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        var view = inflater.inflate(R.layout.dialog_registration, container, false)
        return view

    }
}
Run Code Online (Sandbox Code Playgroud)

android kotlin bottom-sheet android-bottomsheetdialog bottomsheetdialogfragment

1
推荐指数
1
解决办法
5371
查看次数