Android Dialog black edge removal method
- 2020-06-07 05:16:30
- OfStack
An example of Dialog in Android shows how to remove black edges. And it is divided into two methods: to keep the shadow and not to keep the shadow. For your reference. Specific implementation methods are as follows:
1. Do not keep shadows
The code is as follows:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="dialog" parent="@android:style/Theme.Dialog"><!--name Is a marker for the resources that we use, parent Refers to the parent style that the current style inherits -->
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">false</item>
<item name="android:windowNoTitle">true</item><!-- Hide title bar -->
<item name="android:background">@color/clarity</item>
<item name="android:windowBackground">@drawable/clarity</item><!-- It's important here too. I'm using it here 1 A transparent .9.png Of course #00000000 It's also ok, otherwise it comes out here 1 A black background -->
<item name="android:backgroundDimEnabled">false</item>
</style>
</resources>
2. Keep the shadows
The code is as follows:
<resources>
<style name="dialog" parent="@android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@null</item>
</style>
</resources>
final Dialog dialog = new Dialog(context, R.style.dialog);
dialog.setContentView(view);
dialog.show();
Hopefully, the code in this article has helped you with your Android programming.