Android activity background is not transparent when I use SwipeBackLayout and scroll it under api 21

I am developing my application using SwipeBackLayout, and my activity extends from SwipeBackActivity. The background of the background image is transparent when I scroll back to my devices using android api 21. But it does not work on the device with api 19.

Like this:
this is an image in api 19 device

enter image description here

this image is in api 21 device

enter image description here

and below my .xml style in -v19 values:

<!-- in values-v19 -->
<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:windowIsTranslucent">true</item>
</style>

<style name="AppTheme2" parent="AppBaseTheme">
    <item name="android:windowTranslucentStatus">true</item>
</style>
<style name="WelcomeTheme" parent="AppBaseTheme">
    <item name="android:windowTranslucentStatus">false</item>
    <item name="android:windowFullscreen">true</item>
</style>

and this is my .xml style in values-v21

<!-- in values-v21 -->
<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:windowIsTranslucent">true</item>
</style>

<style name="AppTheme2" parent="AppBaseTheme">
    <item name="android:windowTranslucentStatus">true</item>
</style>

<style name="WelcomeTheme" parent="AppBaseTheme">
    <item name="android:windowTranslucentStatus">false</item>
    <item name="android:windowFullscreen">true</item>
</style>

in manifest.xml:

<application
    android:allowBackup="true"
    android:name=".manager.MyApplication"
    android:label="@string/app_name"
    android:theme="@style/AppTheme"  >
.........
</application>
+4
source share
1 answer

Ah, I get it. due to the code below in my activity:

getWindow().setFormat(PixelFormat.RGB_565);

therefore the background of my activity is not transparent.

0

Source: https://habr.com/ru/post/1621255/


All Articles