style.xml
<style name="define_dialog" parent="android:style/Theme.Dialog">
<item name="android:windowIsFloating">true</item>
<item name="android:windowFrame">@null</item>
<item name="android:windowBackground">@color/white</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:backgroundDimAmount">0.5</item> //背景透明度
<item name="android:windowEnterAnimation">@anim/share_dialog_enter</item>
<item name="android:windowExitAnimation">@anim/share_dialog_exit</item>
</style>
java代码
Dialog dialog = new Dialog(context, R.style.share_dialog);
View v = LayoutInflater.from(context).inflate(R.layout.subject_share_dialog, null);
dialog.setContentView(v);
dialog.getWindow().setGravity(Gravity.BOTTOM);
开发中遇到的问题是对话框后面的遮罩层一直为黑色,原来是设置了
android:backgroundDimAmount 为0.95导致的缘故