顶部和底部的Android Alert Dialog黑条

时间:2015-01-04 13:12:55

标签: android android-layout android-fragments alertdialog android-alertdialog

我遇到的问题是始终在警报对话框中显示对话框。 我不希望在顶部和底部有黑条。

你能帮助我吗?

private void popupDialog(){
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    LayoutInflater inflater = (LayoutInflater) Quiz1.this
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View dialogview = inflater.inflate(R.layout.popup_main, null);
    builder.setView(dialogview);
    closeBtn = (ImageButton) dialogview.findViewById(R.id.Rahmen);

    final AlertDialog popupDia =builder.create();
    popupDia.setCanceledOnTouchOutside(true);
    popupDia.setCancelable(true);

    popupDia.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            popupDia.dismiss();
        }
    });

    closeBtn .setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            popupDia.dismiss();
        }
    });
    popupDia.show();
}

2 个答案:

答案 0 :(得分:0)

如果您不想要黑色条形图,只需从清单中更改应用程序的主题,使用浅色主题而不是黑暗,希望它是您想要的,改变对话框的颜色。

答案 1 :(得分:0)

谢谢,但我已经找到了答案,你能看到吗。

AlertDialog.Builder builder = new AlertDialog.Builder(this);
    LayoutInflater inflater = (LayoutInflater) this
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View dialogview = inflater.inflate(R.layout.popup_main, null);
    ImageButton close = (ImageButton) dialogview.findViewById(R.id.Rahmen);
    final AlertDialog popupDia =builder.create();
    popupDia.setView(dialogview, 0, 0, 0, 0);
    popupDia.setCanceledOnTouchOutside(true);
    popupDia.setCancelable(true);
    popupDia.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            popupDia.dismiss();
        }
    });
    close .setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            popupDia.dismiss();
        }
    });
    popupDia.show();

必须在buildig之后设置setView,就是这样