Create fully material designed bottom dialogs similar to the Android Pay app
DialogSheet
An Android library to create fully material designed bottom dialogs similar to the Android Pay app.
Screenshots
Download the sample apk here.
Usage:
Adding the depencency
Add this to your root build.gradle file:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Now add the dependency to your app build.gradle file:
compile 'com.github.marcoscgdev:DialogSheet:1.0.5'
Creating the dialog with Java
Here is a complete snippet of it usage:
new DialogSheet(this)
.setTitle(R.string.app_name)
.setMessage(R.string.lorem)
.setCancelable(false)
.setPositiveButton(android.R.string.ok, new DialogSheet.OnPositiveClickListener() {
@Override
public void onClick(View v) {
// Your action
}
})
.setNegativeButton(android.R.string.cancel, new DialogSheet.OnNegativeClickListener() {
@Override
public void onClick(View v) {
// Your action
}
})
.setBackgroundColor(Color.BLACK) // Your custom background color
.setButtonsColorRes(R.color.colorPrimary) // Default color is accent
.show();
Creating the dialog with Kotlin
Here is a complete snippet of it usage:
val dialogSheet:DialogSheet = DialogSheet(this@MainActivity)
dialogSheet.setCancelable(false)
.setTitle(R.string.app_name)
.setMessage(R.string.lorem)
.setCancelable(false)
.setPositiveButton(android.R.string.ok) {
// Your action
}
.setNegativeButton(android.R.string.cancel) {
// Your action
}
.setBackgroundColor(Color.BLACK) // Your custom background color
.setButtonsColorRes(R.color.colorPrimary) // Default color is accent
.show()
(TIP) Adding a custom view:
- Via inflated view:
View view = View.inflate(context, R.layout.custom_dialog_view, null);
dialogSheet.setView(view);
- Via layout resource:
dialogSheet.setView(R.layout.custom_dialog_view);
// Access dialog custom inflated view
View inflatedView = dialogSheet.getInflatedView();
Button button = (Button) inflatedView.findViewById(R.id.customButton);
...
See the sample project to clarify any queries you may have.