android - 如何在 Android TV App 中设置画中画 (PiP) 的位置?
问题描述
有没有办法将画中画 (PiP) 窗口放在右上角(或其他地方)而不是屏幕的右下角(默认情况下)?或以编程方式设置确切位置?
解决方案
参考下面的提交,这个设置可以帮助“config_defaultPictureInPictureGravity”
例如重力。顶部 | Gravity.RIGHT 为 0x35
commit 06868c37df46c0c973a96a0a25b1f301384db4be
Author: Winson <winsonc@google.com>
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>
推荐阅读
- python - 如何从从另一个生成器获取每个项目的生成器中产生?
- javascript - 在本地主机上工作但不在生产环境中的可选链接运算符
- python - 简单 Salesforce 中的默认批量大小是多少?
- javascript - 如何在ajax之外访问textStatus
- sas - 更改 sas 中列的长度格式
- perl - 如何在 Perl 中以 utf-16 编码打开 XML 文件?
- sass - Nativescript - 组件内具有 ns-dark 模式的布局的角度更改背景颜色
- php - MYSQL IN 函数 PHP 的问题
- mysql - MySQL说“无法添加外键约束”,我找不到原因
- python - Selenium Python:'ElementNotInteractableException'