我有一个自定义的 AlertDialog,我想使其背景完全透明。
通常为了使活动完全透明,我会执行以下操作
这是对话框代码:
LayoutInflater inflater = getLayoutInflater();
View dialoglayout = inflater.inflate(R.layout.activity_mine1,
(ViewGroup) findViewById(R.layout.mine1));
mine1 = new AlertDialog.Builder(this);
mine1.setView(dialoglayout);
mine1.show();
我的 xml 只是一个与其他子视图的relativeLayout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00000000" >
...
</RelativeLayout>
注意:我已经在这里看过一些类似的帖子,但它们似乎不起作用。
我真正的原因是我真正想要使用的背景不是矩形的。我让它在一项活动中发挥作用。但我想用对话框代替。
EDIT:
进一步玩弄,我有这个style.xml
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="CustomDialog" parent="android:Theme.Holo.Dialog">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
</style>
</resources>
我添加为
new AlertDialog.Builder(this, R.style.CustomDialog)