2016-12-26 3 views
2

私はAlertDialogのデザインを変更する方法を知りたい、ボタンの背景。AlertDialogの背景を変更する

ありがとうございました。

new AlertDialog.Builder(this) 
       .setTitle("Exit") 
       .setMessage("Do you want to exit") 
       .setPositiveButton("Yes", new DialogInterface.OnClickListener() { 
        public void onClick(DialogInterface dialog, int which) { 
          finish(); 
        } 
       }) 
       .setNegativeButton("No", new DialogInterface.OnClickListener() { 
        public void onClick(DialogInterface dialog, int which) { 
         // do nothing 
        } 
       }) 
       .setIcon(android.R.drawable.ic_menu_zoom) 
       .show(); 
    } 
+0

あなたはもっと自分の問題@DesignManを記述することができます。 –

+0

あなたはあなたが望むデザインでレイアウトを作成し、同じレイアウトを警告ダイアログで設定することができます。 –

+0

はい、どうすればAlertDialogのようにすることができますか?私は新しいレイアウトの高さと幅をどのように定義できるのでしょうか? – DesignMan

答えて

0
AlertDialog.Builder alertDialog_ImageSelector=new AlertDialog.Builder(mcontext); 
        View imageGuideLineInfo=getActivity().getLayoutInflater().inflate(R.layout.your_alyout,null); 
        alertDialog_ImageSelector.setView(imageGuideLineInfo); 
        TextView tv_guidelines=(TextView)imageGuideLineInfo.findViewById(R.id.tv_guidelines); 
        final AlertDialog adinfo=alertDialog_ImageSelector.create(); 
        adinfo.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));//here you can change the background of alertDialog. 
        adinfo.show(); 

あなたはボタンの背景を変更したい場合、あなたはyour_view.xmlでボタンを作成し、ここにsetBackgroundそれらをバインドする必要があります。

+0

を使用しています。お願いします。 – DesignMan

+0

これらのボタンをレイアウトに作成し、ここにバインドする必要があります。 TextViewのやり方を見てください。今私はtv.setBackgroundColor(Color.RED)としてTextViewの背景を設定することができます;あなたのケースではそれはボタンでなければなりません –

+0

ありがとう@Rushi Ayyappa! – DesignMan

0

使用このアンドロイド作り付けのテーマは

AlertDialog.Builder builder = new AlertDialog.Builder(this, AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);