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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As far as I can see from the code of
AlertDialogandAlertControlleryou can’t access theTextViews responsible for message and title.You can use reflection to reach
mAlertfield in AlertDialog instance, and then again use reflection to accessmMessageandmTitlefields ofmAlert. Though I wouldn’t recommend this approach as it relies on internals (which might change in future).As another (and probably much better) solution, you can apply custom theme via
AlertDialogconstructor. This would allow you to right-justify allTextViews in that dialog.This should be easier and more robust approach.
Here is step by step instructions:
Step 1. Create
res/values/styles.xmlfile. Here its content:Step 2. Create
RightJustifyAlertDialog.javafile. Here its content:Step 3. Use
RightJustifyAlertDialogdialog:Step 4. Check the results: