i use MaterialDialog
version 3.1.1
in this address.
i want align right or center title and message in dialog but can't find how to do this in doc.
i check this page https://github.com/afollestad/material-dialogs/issues/434 and somebody use MaterialDialog.Builder
like this code:
new MaterialDialog.Builder(MainActivity.this)
.titleGravity(GravityEnum.END)
.contentGravity(GravityEnum.END)
.title("چقدر عجله داری بابا!")
.content("این ویژگی در نسخهی بعدی فعال خواهد شد! برو بعدن بیا!")
.positiveText("باشه. :(")
.negativeText("چه بهد")
.typeface("iran_sans_bold","iran_sans")
.callback(new MaterialDialog.ButtonCallback() {
@Override
public void onPositive(MaterialDialog dialog) {
Log.wtf("+","shod");
}
@Override
public void onNegative(MaterialDialog dialog) {
Log.wtf("-","shod");
}
})
.show();
but it seams builder remove in this version. how can i do this?
Update 1:
MaterialDialog
support change layoutDirection base on android system language but i have different situation and i want change layoutDirection base on content
You cannot do it with default Dialog. But obviously, you can start with your own layout on the dialog.
Custom AlertDialog
This full example includes passing data back to the Activity.
Create a custom layout
A layout with an
EditText
is used for this simple example, but you can replace it with anything you like.custom_layout.xml
Use the dialog in code
The key parts are
setView
to assign the custom layout to theAlertDialog.Builder
This is the full code from the example project shown in the image above:
MainActivity.java
Notes
DialogFragment
subclass as is described in the documentation.See also