2016-01-23 95 views
-3

的爲什麼我的警告對話框看起來並不像一個窗口,看一個警告對話框

預計:expected alert dialog但我得到的是

實際:actual alert dailog

如何獲得預期的警報dailog?

+0

查看材料設計,你需要選擇一些東西... – LamonteCristo

+0

謝謝你們,謝謝你的迴應,我已經改變了使用ContextThemeWrapper類的警報對話框的風格。 – srinivas

回答

0

您將需要爲您的願望定製設計。使用這種方法

@TargetApi(Build.VERSION_CODES.JELLY_BEAN) 
private void emailDialog() { 

    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity()); 
    LayoutInflater inflater = getActivity().getLayoutInflater(); 
    View dialogView = inflater.inflate(R.layout.dialog, null); 
    dialogBuilder.setView(dialogView); 
    AlertDialog alertDialog = dialogBuilder.create(); 

    TextView textView = (TextView) dialogView.findViewById(R.id.textView); 
    TextView textView2 = (TextView) dialogView.findViewById(R.id.textView2); 
    textView.setBackground(getResources().getDrawable(R.drawable.dialog_header_background_blue)); 
    alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); 

    textView.setText("EMAIL SENT"); 
    textView2.setText("Link has been sent to your Email"); 
    alertDialog.show(); 
} 
0

我不認爲你可以改變警告對話框的外觀,只是讓它像現在一樣。

我認爲警報對話框的外觀因主題而異。 嘗試改變你的活動的主題,也許全息,它可能看起來不同!你可以不斷改變它,直到你找到你想要的東西。