Is there a way to put the Picture in Picture (PiP) window to the upper right corner (or somewhere else) instead of lower right corner of the screen (by default)? or programmatically set the exact location?
How to Set the Position of Picture in Picture (PiP) in Android TV App?
3k views Asked by burakk At
2
There are 2 answers
1
On
refer to below commit, this setting can help "config_defaultPictureInPictureGravity"
and you can refer https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/view/Gravity.java;l=45 to find out the value you need
e.g. Gravity.TOP | Gravity.RIGHT is 0x35
commit 06868c37df46c0c973a96a0a25b1f301384db4be
Author: Winson <[email protected]>
Date: Wed Oct 12 21:08:18 2016 -0700
Changing initial PIP bounds specifications.
- Change from a absolute bounds to a size, gravity and inset to
allow easier tweaking of initial pinned stack bounds.
Test: android.server.cts.ActivityManagerPinnedStackTests
Test: #testPinnedStackDefaultBounds
Test: #testPinnedStackMovementBounds
Change-Id: I82a102bbd2d83259c6c84915071d1a16728e3aa7
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index c40436a5bda..30dcfb081d8 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -2482,8 +2482,17 @@
-->
<integer name="config_navBarOpacityMode">0</integer>
- <!-- Default bounds [left top right bottom] on screen for picture-in-picture windows. -->
- <string translatable="false" name="config_defaultPictureInPictureBounds">"0 0 100 100"</string>
+ <!-- Default insets [LEFT/RIGHTxTOP/BOTTOM] from the screen edge for picture-in-picture windows.
+ These values are in DPs and will be converted to pixel sizes internally. -->
+ <string translatable="false" name="config_defaultPictureInPictureScreenEdgeInsets">10x10</string>
+
+ <!-- Max default size [WIDTHxHEIGHT] on screen for picture-in-picture windows to fit inside.
+ These values are in DPs and will be converted to pixel sizes internally. -->
+ <string translatable="false" name="config_defaultPictureInPictureSize">216x135</string>
+
+ <!-- The default gravity for the picture-in-picture window.
+ Currently, this maps to Gravity.BOTTOM | Gravity.RIGHT -->
+ <integer name="config_defaultPictureInPictureGravity">0x55</integer>
I think there's no documentation about changing the position of the Picture in Picture window unless you will drag the window itself.