这是我第一次使用BottomSheetDialog, 代码是这样的:
final BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this);
bottomSheetDialog.setTitle("title");
//bottomSheetDialog.setContentView(...)
bottomSheetDialog.show();
当我运行此代码时,标题没有显示。
你能解释一下这段代码发生了什么变化吗?谢谢〜
答案 0 :(得分:8)
如果你查看android.support.design.widget.BottomSheetDialog
的源代码,你会发现,在它的构造函数中有一行:
// We hide the title bar for any style configuration. Otherwise, there will be a gap
// above the bottom sheet when it is expanded.
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
明确指出,底部表格没有标题(有理由)。 (截至支持库版本23.4.0)
建议: 在底部工作表的布局中创建视图的标题。