Android自定义Dialog去黑框

去掉黑框 style

1
2
3
4
5
6
7
<style name="dialog" parent="@android:style/Theme.Dialog">
<item name="android:windowNoTitle">true</item>
<item name="android:background">@android:color/transparent</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowIsTranslucent">true</item>
</style>

使用

1
2
3
4
5
6
Dialog dialog = new Dialog(this, R.style.dialog);
View view = getLayoutInflater().inflate(R.layout.dialog_us, null, false);
//TODO views process
dialog.setContentView(view);
dialog.setCanceledOnTouchOutside(false);
dialog.show();