【发布时间】:2011-02-17 21:34:57
【问题描述】:
我正在创建一个带有圆角背景图像的自定义对话框。我使用自定义样式删除了白色边框,但它显示为好像在我的图像后面有一个相同大小的黑色矩形,如下所示(对话框的背景图像是棕色的):
如何让图片的透明背景与圆角保持一致?
我的对话框布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/confirmation"
android:orientation="vertical"
android:background="@drawable/dialog_background"
android:layout_width="279dp"
android:layout_height="130dp"
>
...
我通过将以下样式应用于我的对话框来删除白色边框:
<style
name="Theme_Dialog_Translucent"
parent="android:Theme.Dialog">
<item name="android:windowBackground">@null</item>
</style>
我的 CustomDialog 类是:
public class CustomDialog extends Dialog implements OnClickListener {
Button okButton;
public CustomDialog(Context context) {
// Custom style to remove dialog border - corners black though :(
super(context, R.style.Theme_Dialog_Translucent);
// 'Window.FEATURE_NO_TITLE' - Used to hide the title
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.custom_dialog);
okButton = (Button) findViewById(R.id.button_ok);
okButton.setOnClickListener(this);
}
...
}
【问题讨论】:
标签: android image dialog transparent