I have a sidemenu activity which appears over another activity.
<style name="Sidemenu" parent="Usual">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:colorBackgroundCacheHint">@null</item>
</style>
It has been working perfectly. As normal, you can see the activity below.
However I simply updated Android Studio to 4.2RC1..
and now.. it does not work!
The under area is black.
Total mystery.
Any solutions around?
courtesy this amazing old post where there was a similar problem a few years ago: https://stackoverflow.com/a/35915764/294884
(1) It's yet another droid activity/theme bug
(2) In manifest you MUST set the theme to Theme.AppCompat.Dialog
// side menu
<activity android:name=".. LeftMenu" android:theme="@style/Theme.AppCompat.Dialog" />
<!-- beware of insane droid transparent activity bug... -->
(3) Only in code , can you set the theme to your theme. (Do so before super)
protected void onCreate(Bundle savedInstanceState) {
setTheme(R.style.YourTransparentTheme);
super.onCreate(savedInstanceState);
setContentView(R.layout.aty_leftmenu);
}
(4) Your own theme in styles will be:
<style name="YourTransparentTheme" parent="YourGeneralTheme">
<item name="android:windowBackground">@android:color/transparent</item>
.. and other colors etc you desire ..
</style>
Details on why you only need windowBackground: https://stackoverflow.com/a/67040753/294884
In summary the workaround for the bug is:
(Aside: Note that it is no problem if most of your activities have a title bar (so based on Theme.AppCompat.Light), but your transparent activity has no title bar (so based on Theme.AppCompat.Light.NoActionBar). In that way you can have the usual thing where a "left menu" or similar covers also the title bar of the main app.)
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.