BottomDialog
BottomDialog is an Android library that shows a slide-up animation dialog from the bottom of the screen. Something like on iOS. It is intended to be used for dialogs with yes/no/cancel answers. It is customizable so you can style it as you like.
Implementation
Gradle
implementation("com.kovacivan:BottomDialog:1.1")
Links
Usage
If you only want to see how it works:
BottomDialog(this, binding.root)
.showBottomDialog()
Set button text:
BottomDialog(this, binding.root) .topButtonText("Delete") .bottomButtonText("Edit") .cancelButtonText("Cancel") .showBottomDialog()
And this is how you get a return from button clicks:
class MainActivity : AppCompatActivity(), BottomDialogListener { ... val bottomDialog = BottomDialog(this, binding.root) .topButtonText("Delete") .bottomButtonText("Edit") .cancelButtonText("Cancel") .showBottomDialog() ... override fun topButtonClicked() { // Do your stuff here } override fun bottomButtonClicked() { // Do your stuff here } override fun cancelButtonClicked() { // Do your stuff here } }
Button click example:
override fun topButtonClicked() { Snackbar.make( binding.root, "Top button clicked", Snackbar.LENGTH_SHORT ).show() } override fun bottomButtonClicked() { Snackbar.make( binding.root, "Bottom button clicked", Snackbar.LENGTH_SHORT ).show() } override fun cancelButtonClicked() { Snackbar.make( binding.root, "Cancel button clicked", Snackbar.LENGTH_SHORT ).show() }
All options
Option | Description |
---|---|
animationDuration(Long) | Set the duration of the animation in milliseconds |
title(String) | Set the text of the title |
titleTextSize(Int) | Change the text size for the title |
titleTextColor(Int) | Change title text color (eg. Color.RED) |
titleTypeface(Int) | Change title text Typeface (eg. Typeface.BOLD) |
topButtonText(String) | Set text for the top button |
topButtonTextSize(Int) | Change the size of the top button text |
topButtonTextColor(Int) | Change the color of the top button (eg. Color.RED) |
topButtonTypeface(Int) | Change top button text Typeface (eg. Typeface.BOLD) |
hideTopButton(Boolean) | Hide top button |
bottomButtonText(String) | Set text for the bottom button |
bottomButtonTextSize(Int) | Change the size of the bottom button text |
bottomButtonTextColor(Int) | Change the color of the bottom button (eg. Color.RED) |
bottomButtonTypeface(Int) | Change bottom button text Typeface (eg. Typeface.BOLD) |
cancelButtonText(String) | Set text for the cancel button |
cancelButtonTextSize(Int) | Change the size of the cancel button text |
cancelButtonTextColor(Int) | Change the color of the cancel button (eg. Color.RED) |
cancelButtonTypeface(Int) | Change cancel button text Typeface (eg. Typeface.BOLD) |
backgroundOverlay(Boolean) | Set a transparent overlay over your layout |
backgroundOverlayTransparencyPercentage(Float) | Set the percentage of background overlay transparency |
backgroundOverlayColor(Int) | Change the color of the overlay (eg. Color.RED) |
hideOnBackgroundClick(Boolean) | Hides bottom dialog on background click |
showBottomDialog() | Shows bottom dialog (MUST BE CALLED LAST) |
If you have some ideas about what should I add or change, or maybe you have some issues with this library, please let me know. I will be happy to hear your feedback.