2012-01-16 2 views

Répondre

5

A propos de la taille de la police que vous pouvez utiliser ceci:

SpannableStringBuilder ssBuilser = new SpannableStringBuilder("Sample"); 
StyleSpan span = new StyleSpan(Typeface.ITALIC); 
ScaleXSpan span1 = new ScaleXSpan(1); 
ssBuilser.setSpan(span, 0, 5, Spanned.SPAN_INCLUSIVE_INCLUSIVE); 
ssBuilser.setSpan(span1, 0, 5, Spanned.SPAN_INCLUSIVE_INCLUSIVE); 

AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); 

builder.setTitle(ssBuilser); 

builder.show(); 

Vous pouvez aussi définir titre personnalisé:

float size = 25;  

AlertDialog.Builder builder = new AlertDialog.Builder(this);  
final TextView myView = new TextView(getApplicationContext()); 
myView.setText("A Sample Title to Change Dialog Title"); 
myView.setTextSize(size); 
builder.setCustomTitle(myView); 
+0

cela ne fonctionne pas pour moi.je besoin de la taille du texte comme 12dp ou 14dp .can vous me dire comment puis-je faire cela – Meghna

+0

J'ai mis à jour mon poste, vous pouvez l'essayer. Vous pouvez utiliser les métriques d'affichage pour obtenir la taille en dp. Par exemple: 14 * getResources(). GetDisplayMetrics(). Density; –

3

Yo peut créer youtr propre boîte de dialogue de sorte que vous pouvez définir la mise en page que vous voulez:

Dialog dialog = new Dialog(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); 

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


    Button ok = (Button) dialog.findViewById(R.id.ok); 
    //you can change the button dimensions here 
    ok.setOnClickListener(new OnClickListener(){ 
     public void onClick(View v) { 
      //actions 
     } 
    }); 

    dialog.show(); 

Cordialement.

Questions connexes