背景如何变暗,就像显示here一样?
我已使用CoordinatorLayout
和BottomSheetBehavior
正常设置。
答案 0 :(得分:4)
这只会显示一个底页。
public class MyBottomSheet extends BottomSheetDialogFragment {
private static final String TAG = "MyBottomSheet";
@NonNull
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
final BottomSheetDialog dialog = (BottomSheetDialog) super.onCreateDialog(savedInstanceState);
final View view = View.inflate(getContext(), R.layout.my_custom_view, null);
dialog.setContentView(view);
behavior = BottomSheetBehavior.from((View) view.getParent());
return dialog;
}
public void show(final FragmentActivity fragmentActivity) {
show(fragmentActivity.getSupportFragmentManager(), TAG);
}
}
要像普通电话close()
一样关闭对话框。
答案 1 :(得分:0)
使用BottomSheetDialog
基本上它是一个对话框(即支持暗淡)并且支持模态底页行为试一试
答案 2 :(得分:0)
bottomSheetBehavior.addBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {}
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
(your_layout/view).setAlpha(1 - slideOffset);
}
});