Moh*_*pal 7 layout resize android-layout
我正在尝试在我的应用中实现画中画模式。我正在 PIP 模式下实现谷歌地图,但我无法调整全屏地图的大小。它总是放大地图中心点。我已经完成了与此问题相关的研发,但没有找到任何正确的答案。基本上,我需要在我的应用程序上像 Whatsapp app pip Screen 这样的布局如何实现它?我的代码在这里:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Display display=getWindowManager().getDefaultDisplay();
Point size=new Point();
display.getSize(size);
int width=size.x;
int height=size.y;
Rational aspectRatio=new Rational(width,height);
PictureInPictureParams params = new PictureInPictureParams.Builder()
.setAspectRatio(aspectRatio).build();
enterPictureInPictureMode(params);
}
Run Code Online (Sandbox Code Playgroud)
这是清单代码:
<activity android:name=".activities.MainActivity"
android:supportsPictureInPicture="true"
android:resizeableActivity="true"
android:launchMode="singleTask"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"/>
Run Code Online (Sandbox Code Playgroud)
在这段代码中,我有这样的屏幕
而且我要
我该如何解决这个问题?
提前致谢!!
Moh*_*pal -4
只需更改您的此代码
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Display display=getWindowManager().getDefaultDisplay();
Point size=new Point();
display.getSize(size);
int width=size.x;
int height=size.y;
Rational aspectRatio=new Rational(width,height);
PictureInPictureParams params = new PictureInPictureParams.Builder()
.setAspectRatio(aspectRatio).build();
enterPictureInPictureMode(params);
}
Run Code Online (Sandbox Code Playgroud)
到
Rational aspectRatio = new Rational(3, 4);
PictureInPictureParams params = new PictureInPictureParams.Builder()
.setAspectRatio(aspectRatio).build();
enterPictureInPictureMode(params);
Run Code Online (Sandbox Code Playgroud)