android - 想像附件一一样创建BottomSheetDialogFragment
解决方案
这是一个例子:
public class ExampleFragment extends BottomSheetDialogFragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View view = inflater.inflate(R.layout.fragment_pdf_view, container, false);
//Views
return view;
}
@Override
public void onResume() {
super.onResume();
}
@Override
public int getTheme() {
return R.style.AppBottomSheetDialogTheme;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
BottomSheetDialog dialog = (BottomSheetDialog) super.onCreateDialog(savedInstanceState);
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
BottomSheetDialog d = (BottomSheetDialog) dialog;
FrameLayout bottomSheet = d.findViewById(R.id.design_bottom_sheet);
BottomSheetBehavior.from(bottomSheet).setState(BottomSheetBehavior.STATE_EXPANDED);
}
});
// Do something with your dialog like setContentView() or whatever
return dialog;
}
}
推荐阅读
- image - 不支持内容类型“application/octet-stream”(颤振 dio)
- java - 如何在 HashSet 中调用特定对象的函数
- android - 使用 Cordova 版本 10.0.0 和节点 v16.4.2 的 Cordova 构建失败
- ios - iPhone应用程序可以修改iOS中的数据,这些数据指定手机屏幕上其他应用程序图标的位置(点)吗?
- java - Firebase 实时数据库(Android-Java)-“类未定义无参数构造函数”
- javascript - Docker TypeScript:更改文件时没有热加载
- flutter - 如何让 scrollController.listener 监听变化?
- wordpress - 如何在 WordPress 中更改网站徽标 URL
- wordpress - 在php中的组件之间共享数据的最佳方式是什么
- rust - 为什么我的价值观之一没有移动到我的异步块中?