When I start a new popup activity (just a scaled activity), everything works fine on the newest android version, but the background slowly turns black on v26 (Android 8.0).
I use getWindow().setLayout()
to scale the activity.
My theme:
<style name="PopupTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowCloseOnTouchOutside">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
</style>
This is how the activity looks after it slowly went darker:
I found this problem nowhere on StackOverflow, does somebody know about it?
Reason
It seems to be an issue with some Android versions.
There are 2 thinks that are not supported together:
android:windowIsTranslucent
and android:orientation
.
If one translucent Activity is above an Activity with a different orientation, there is nothing Android can display.
But the developers of Android did not enable it if both orientations are the same , but rather just disabled changing the orientation completely and only enabled setting it to the one of its parent (default). This behaviour was changed in newer versions.
Solution
Either use
android:windowIsTranslucent = false
or leave out
android:orientation
in your popup-Activity.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.