Using floating/translucent windows with Android PIP causes a 3 second delay plus scaling issues. I've put together a sample app to demo the problem. I'm thinking there is some combination of tags I am either using incorrectly or completely missing some tag or tags. I tried many different combinations and came up with a few combos to demo the problem. I'll add code portions to give you and idea of what I am doing. I'll add additional or full code as needed. I want to try and keep this question compact but it may become long as I add more of the sample app necessary for you to actually run the app on your development environment.
Here are the significant sections from styles.xml for the test app:
<!--== ERROR CASE #1=================================-->
<!-- Causes 3 second delay to get into PIP mode -->
<!-- Incorrect window scale during 3 second delay -->
<!-- Incorrect window size after PIP exit -->
<!--=================================================-->
<item name="android:windowIsFloating">true</item>
<!--=================================================-->
<!--== ERROR CASE #2=================================-->
<!-- Causes 3 second delay to get into PIP mode-->
<!-- Window is not transparent -->
<!--=================================================-->
<item name="android:windowIsTranslucent">true</item>
<!--=================================================-->
<!--== ERROR CASE #3=================================-->
<!-- Causes 3 second delay to get into PIP mode -->
<!-- Incorrect window scale during 3 second delay -->
<!-- Incorrect window scale after PIP exit -->
<!--=================================================-->
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowIsFloating">true</item>
<!--=================================================-->
The following image is the initial app screen (as expected):
.
Putting the app into PIP mode causes this screen for three seconds (unexpected delay and bad scale):
.
After 3 seconds, PIP mode is enabled ( expected image )

Exiting PIP results in an unusable activity due to bad scaling:

I'll add additional code snippets as necessary. But for now, I'm thinking styles.xml file is incorrect.
Here is styles:
<resources>
<style name="StyleJava42" parent="Theme.AppCompat">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowFullscreen">false</item>
<!--== ERROR CASE #1=================================-->
<!-- Causes 3 second delay to get into PIP mode -->
<!-- Incorrect window scale during 3 second delay -->
<!-- Incorrect window size after PIP exit -->
<!--=================================================-->
<item name="android:windowIsFloating">true</item>
<!--=================================================-->
<!--== ERROR CASE #2=================================-->
<!-- Causes 3 second delay to get into PIP mode-->
<!-- Window is not transparent -->
<!--=================================================-->
<item name="android:windowIsTranslucent">true</item>
<!--=================================================-->
<!--== ERROR CASE #3=================================-->
<!-- Causes 3 second delay to get into PIP mode -->
<!-- Incorrect window scale during 3 second delay -->
<!-- Incorrect window scale after PIP exit -->
<!--=================================================-->
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowIsFloating">true</item>
<!--=================================================-->
</style>
</resources>
And here is the manifest:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat"
>
<activity
android:theme="@style/StyleJava42"
android:name=".MainActivity"
android:supportsPictureInPicture="true"
>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Bottom line, I need a usable transparent window going in to and out of PIP mode that does not cause scaling problems.
from Scaling problems and 3 second delay entering/exiting Picture-in-Picture mode with Floating / Translucent windows
No comments:
Post a Comment