Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Right justify text in AlertDialog

Is it possible to right-justify the text in an AlertDialog's title and message?

I am showing Hebrew messages but they are showing up left justified.

like image 968
theblitz Avatar asked May 25 '11 21:05

theblitz


People also ask

Is AlertDialog deprecated?

A simple dialog containing an DatePicker . This class was deprecated in API level 26.

What is the difference between dialog and AlertDialog?

AlertDialog is a lightweight version of a Dialog. This is supposed to deal with INFORMATIVE matters only, That's the reason why complex interactions with the user are limited. Dialog on the other hand is able to do even more complex things .

Which method is used to set in AlertDialog?

setIcon() method is use to set the icon on Alert dialog box.

What is AlertDialog message?

AlertDialog. A dialog that can show a title, up to three buttons, a list of selectable items, or a custom layout. DatePickerDialog or TimePickerDialog. A dialog with a pre-defined UI that allows the user to select a date or time.


1 Answers

This is an old question, but there is a very simple solution. Assuming you are using MinSdk 17, you can add this to your styles.xml:

<style name="AlertDialogCustom" parent="ThemeOverlay.AppCompat.Dialog.Alert">
    <item name="android:layoutDirection">rtl</item>
</style>

And in the AlertDialog.Builder you just need to specify this AlertDialogCustom in the constructor:

new AlertDialog.Builder(this, R.style.AlertDialogCustom)
                    .setTitle("Your title?")
                    .show();
like image 182
yshahak Avatar answered Sep 30 '22 18:09

yshahak