2017-11-26 4 views
1

「ログアウトしますか?」という質問を設定し、次にbuilder.setPositiveButtonおよびbuilder.setNegativeButtonとしてYESまたはNOを設定します。しかし、YESとNOの単語は小さすぎます。どうすればそれらを大きくすることができますか?ここでは、「ログアウト」の項目をクリックするとalertDialogがポップアップしたときに、私は私のNavigationDrawerに持っているものです。alertDialogでbuilder.setPositiveButtonとbuilder.setNegativeButtonsを大きくするにはどうすればいいですか?

enter image description here

ここalertDialogのためのコードは次のとおりです。

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

     builder.setCancelable(false); 

     builder.setTitle("Are you sure you want to Log Out?"); 

     builder.setNegativeButton("NO", new DialogInterface.OnClickListener() { 

     public void onClick(DialogInterface dialog, int WhichButton) { 
     dialog.cancel(); 
     } 
     }); 
     builder.setPositiveButton("YES", new DialogInterface.OnClickListener() { 
     public void onClick(DialogInterface dialog, int which) { 
      } 
      }); 

      builder.show(); 

ので、私はちょうど作るために探しています「はい」と「いいえ」という言葉が大きければ、どうすればいいですか?

+1

独自のレイアウトを使用する必要があります – diegoveloper

答えて

0

Defalut AlertDialogのスタイルを設定することも、独自のカスタムレイアウトXMLファイルを作成することもできます。スタイリングのために

1):

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <style name="AlertDialogCustom" parent="@android:style/Theme.Dialog"> 
     <item name="android:textColor">#00FF00</item> 
     <item name="android:typeface">monospace</item> 
     <item name="android:textSize">10sp</item> 
    </style> 
</resources> 

2)カスタムダイアログの場合:

AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this); 
LayoutInflater inflater = this.getLayoutInflater(); 
View dialogView = inflater.inflate(R.layout.alert_label_editor, null); 
dialogBuilder.setView(dialogView); 

EditText editText = (EditText) dialogView.findViewById(R.id.label_field); 
editText.setText("test label"); 
AlertDialog alertDialog = dialogBuilder.create(); 
alertDialog.show(); 

R.layout.alert_label_editorは、独自のカスタムレイアウトファイルです。

関連する問題