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

3

24

Which component do I choose to achieve custom dialog at the bottom as shown in the below image? Shall I choose alertdialog,popupwindow, or fragmentdialog?

dialogAtBottom

Chemisette answered 18/2, 2017 at 12:29 Comment(3)
you can use popup window & give in animation for bottom to showExhibitor
Use BottomSheetDialog with custom layout.Vilayet
mayojava.github.io/android/bottom-sheets-androidZarathustra
V
83

Try this

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

dialog.show();
Vilayet answered 18/2, 2017 at 12:34 Comment(2)
For a great tutorial see: medium.com/glucosio-project/…Ox
@ak sacha GREAT straightforward answer.Authoritative
D
3

Edit: I didn't there was a built in component in Android to do so. Good to know! Also, check this out:

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

I would recommend FragmentDialog without a doubt.

It's so much easier to create a customized Dialog regarding location & layout design.

Dimity answered 18/2, 2017 at 12:33 Comment(0)
P
0

Kotlin code for run custom ButtomSheetDialog (run inside Activity)

 var CustomSelectProfilePicBottomSheetDialog  =   BottomSheetDialog(this)
  val   layoutButtomSheetView  = this.layoutInflater.inflate(R.layout.ly_custom_buttom_sheet_frg_dialog, null)
   CustomSelectProfilePicBottomSheetDialog.setContentView(layoutButtomSheetView)
  CustomSelectProfilePicBottomSheetDialog.show()
Polak answered 23/1, 2019 at 6:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.