-1

I am trying to use alert dialog. Is there a way I can set the message text size?

I tried a work around by setting the dialog view to a textview and loading this textview with htmlformatted string. I called set text size on the textview and some of the words appeared and some not.

So i was wondering if there is a less convoluted way or if Iam doing anything wrong?

Thank you

Snake
  • 14,228
  • 27
  • 117
  • 250

3 Answers3

3

try this code

 AlertDialog dialog = new AlertDialog.Builder(this).setMessage("Hello world").show();
   TextView textView = (TextView) dialog.findViewById(android.R.id.message);
    textView.setTextSize(40);
pavanmvn
  • 749
  • 10
  • 21
1

Try this

public static void exitAlert(final Context context)
    {
        AlertDialog.Builder builder = new Builder(context);
        builder.setMessage("Do you want to exit?");
        TextView title =  new TextView(context);
        title.setText("Increase Text");
        title.setGravity(Gravity.CENTER);
        title.setTextSize(30);
        title.setBackgroundColor(Color.GRAY);
        title.setTextColor(Color.WHITE);

        builder.setCustomTitle(title);
        builder.setPositiveButton("Ok", new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) 
            {
                ((Activity) context).finish();
            }  
        });

        builder.setNegativeButton("Cancel", new OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {


            }
        });
        builder.show();
    }
jyomin
  • 1,957
  • 2
  • 11
  • 27
-1
{
    TextView tv=new TextView(getApplicationContext());

    tv.setText("sdf");

    tv.setTextSize(45);
    dialog.setMessage(String.valueOf(tv));
}
Adi Inbar
  • 12,097
  • 13
  • 56
  • 69