android - AlertDialog设计中的问题

标签 android xml android-alertdialog

我正在尝试设计 AlertDialog,但我无法摆脱黑色周围(如红线所示)和橙色周围(如蓝线所示)。 enter image description here

这是我的 xml 代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:background="@android:color/darker_gray" >

    <TextView
        android:src="@drawable/save_as"
        android:id="@+id/label_save_as"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="@android:color/black"
        android:text="@string/save_as" />

    <EditText
        android:id="@+id/filename"
        android:inputType="textEmailAddress"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        android:layout_marginLeft="4dp"
        android:layout_marginRight="4dp"
        android:layout_marginBottom="4dp"
        android:hint="@string/filename" />

</LinearLayout>

这是代码:

AlertDialog.Builder saveAsBuilder = new AlertDialog.Builder(this);
    LayoutInflater saveAsInflater = this.getLayoutInflater();       
    saveAsBuilder.setView(saveAsInflater.inflate(R.layout.saveas, null))
                 .setNeutralButton(R.string.saveAsImg, new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int id) {
                            // do something
                     }
               })
               .setPositiveButton(R.string.saveAsSkt, new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int id) {
                               // do something
                   }
            });      
    d = saveAsBuilder.create();
    d.setCanceledOnTouchOutside(true);
    d.show();

我怎样才能摆脱那些? 顺便说一句,我正在使用 API 10。

最佳答案

一旦尝试像这样改变并尝试..

AlertDialog.Builder saveAsBuilder = new AlertDialog.Builder(this,android.R.style.Theme_Translucent);

设置对话框的主题以去除黑色空格

使用对话框..

    Dialog dialog=new Dialog(getApplicationContext());
    dialog.setContentView(R.layout.yourlayout);

为此,您必须在布局中创建两个按钮并为其实现监听器..

关于android - AlertDialog设计中的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20719063/

相关文章:

java - 用 View (按钮)覆盖 Android AlertDialog

android - 如何区分 Longclicks 和 onclick 事件?

Android studio 2.1.2 gradle aapt语法错误: Unterminated quoted string

java - Web Java 应用程序中的 xml 属性文件位置

android - 编辑文本作为微调器

java - Spring添加mvc :resources tag

Python Minidom XML 查询

android - 在 Android 中扩展 AlertDialog(在哪里可以找到示例,如何获取标题和按钮)

当我在 HTTP 请求中使用 Get 方法时出现 java.io.FileNotFoundException

android - 要实现 Android 夜间模式,使用 UiModeManager 并启用汽车模式,但显示通知,这可能不是好方法