Skip to content Skip to sidebar Skip to footer

How To Reduce Alertdialog.builder Title Font Size And Positive Button Size?

Is it possible to reduce the AlertDialog.Builder title font size and positive button size? If yes, Just let me how to do?

Solution 1:

About font size you can use this:

SpannableStringBuilderssBuilser=newSpannableStringBuilder("Sample");
StyleSpanspan=newStyleSpan(Typeface.ITALIC);
ScaleXSpanspan1=newScaleXSpan(1);
ssBuilser.setSpan(span, 0, 5, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
ssBuilser.setSpan(span1, 0, 5, Spanned.SPAN_INCLUSIVE_INCLUSIVE);

AlertDialog.Builderbuilder=newAlertDialog.Builder(MainActivity.this);

builder.setTitle(ssBuilser);

builder.show();

Also You can set custom title:

floatsize=25;    

AlertDialog.Builderbuilder=newAlertDialog.Builder(this);    
finalTextViewmyView=newTextView(getApplicationContext());
myView.setText("A Sample Title to Change Dialog Title");
myView.setTextSize(size);
builder.setCustomTitle(myView);

Solution 2:

Yo can create youtr own dialog so you can set the layout as you want:

Dialogdialog=newDialog(act,R.style.MyTheme);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setOwnerActivity(act);
    //In the layout XML you can set the text size or the button size. 
    dialog.setContentView(R.layout.dialog_layout);

    TextViewtext= (TextView) dialog.findViewById(R.id.text);
    //you can set your text size here
    text.setTextSize(mySize);
    text.setText("my text"); 


    Buttonok= (Button) dialog.findViewById(R.id.ok);
    //you can change the button dimensions here
    ok.setOnClickListener(newOnClickListener(){
        publicvoidonClick(View v) {
            //actions
        }
    });

    dialog.show();

Regards.

Post a Comment for "How To Reduce Alertdialog.builder Title Font Size And Positive Button Size?"