2016-01-23 93 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

我不认为你可以改变警告对话框的外观,只是让它像现在一样。

我认为警报对话框的外观因主题而异。 尝试改变你的活动的主题,也许全息,它可能看起来不同!你可以不断改变它,直到你找到你想要的东西。