Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5940089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:55:11+00:00 2026-05-22T15:55:11+00:00

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

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T15:55:12+00:00Added an answer on May 22, 2026 at 3:55 pm

    As far as I can see from the code of AlertDialog and AlertController you can’t access the TextViews responsible for message and title.

    You can use reflection to reach mAlert field in AlertDialog instance, and then again use reflection to access mMessage and mTitle fields of mAlert. 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 AlertDialog constructor. This would allow you to right-justify all TextViews in that dialog.

         protected AlertDialog (Context context, int theme)
    

    This should be easier and more robust approach.


    Here is step by step instructions:

    Step 1. Create res/values/styles.xml file. Here its content:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
    
        <style name="RightJustifyTextView" parent="@android:style/Widget.TextView">
            <item name="android:gravity">right|center_vertical</item>
        </style>
    
        <style name="RightJustifyDialogWindowTitle" parent="@android:style/DialogWindowTitle" >
             <item name="android:gravity">right|center_vertical</item>
        </style>
    
        <style name="RightJustifyTheme" parent="@android:style/Theme.Dialog.Alert">
            <item name="android:textViewStyle">@style/RightJustifyTextView</item>       
            <item name="android:windowTitleStyle">@style/RightJustifyDialogWindowTitle</item>       
        </style>    
    
    </resources>
    

    Step 2. Create RightJustifyAlertDialog.java file. Here its content:

    public class RightJustifyAlertDialog extends AlertDialog
    {
        public RightJustifyAlertDialog(Context ctx)
        {
            super(ctx,  R.style.RightJustifyTheme);
        }
    }
    

    Step 3. Use RightJustifyAlertDialog dialog:

    AlertDialog dialog = new RightJustifyAlertDialog(this);
    dialog.setButton("button", new OnClickListener()
    {           
        public void onClick(DialogInterface arg0, int arg1)
        {
    
        }
    });
    dialog.setTitle("Some Title");
    dialog.setMessage("Some message");
    
    dialog.show();
    

    Step 4. Check the results:

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to scroll down the left and right parts of a vertically
is it possible to get the mouse direction (Left, Right, Up, Down) based on
In Javascript, str = 'left ui-tabs ui-widget ui-widget-content center right'; Is it possible to
Cross-browser CSS that works to allow both left and right align of text on
Possible Duplicates: Given a 2d array sorted in increasing order from left to right
I don't think it is possible right now in VS2010/VS2008 but I'm sure someone
Possible Duplicate: How to distinguish between left and right mouse click with jQuery? On
Possible Duplicate: how to rotate the given string to left or right in C?
In MS VisualStudio (I'm using 2005), it's possible to right-click in some code file
Is it possible to add a button to the right corner of the app

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.