我正在尝试设计 AlertDialog,但我无法摆脱黑色周围(如红线所示)和橙色周围(如蓝线所示)。
这是我的 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/