如何在Android中实现屏幕底部的自定义对话框

24

在下图中,我应该选择哪个组件来实现底部自定义对话框?我应该选择 alertdialogpopupwindow 还是 fragmentdialog

dialogAtBottom


你可以使用弹出窗口并添加底部动画来显示。 - user3040153
2
使用自定义布局与 BottomSheetDialog。 - ak sacha
1
https://mayojava.github.io/android/bottom-sheets-android/ - sivaBE35
3个回答

83

试一试这个

BottomSheetDialog dialog = new BottomSheetDialog(YourActivity.this);
dialog.setContentView(YourView);

dialog.show();

3
请看这个优秀的教程:https://medium.com/glucosio-project/moving-from-dialogs-to-bottomsheetdialogs-on-android-15fb8d140295 - BlueBoy
@ak sacha,非常直接明了的回答。 - Arbaz.in

3

0

运行自定义ButtomSheetDialog的Kotlin代码(在Activity内运行)

 var CustomSelectProfilePicBottomSheetDialog  =   BottomSheetDialog(this)
  val   layoutButtomSheetView  = this.layoutInflater.inflate(R.layout.ly_custom_buttom_sheet_frg_dialog, null)
   CustomSelectProfilePicBottomSheetDialog.setContentView(layoutButtomSheetView)
  CustomSelectProfilePicBottomSheetDialog.show()

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接