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

How to achieve custom dialog at the bottom of the screen in Android

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

编辑:Android 中没有内置组件可以执行此操作。很高兴知道!另外,检查一下:

https://medium.com/glucosio-project/moving-from-dialogs-to-bottomsheetdialogs-on-android-15fb8d140295#

毫无疑问,我会推荐 FragmentDialog

创建关于位置和布局设计的自定义 Dialog 非常容易。

试试这个

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

dialog.show();

运行 自定义底部表单对话框(运行 和 Activity)的 Kotlin 代码

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