我正在尝试在我的应用中实现画中画模式。我正在PIP模式下实施Google地图,但无法调整全屏地图的大小。它始终缩放地图中心点。我已经完成了与此问题相关的RND,但未找到任何适当的答案。基本上,我需要在应用程序上实现类似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);
}
这是清单代码:
<activity android:name=".activities.MainActivity"
android:supportsPictureInPicture="true"
android:resizeableActivity="true"
android:launchMode="singleTask"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"/>
在此代码中,我的屏幕类似于
我想要
我该如何解决?
提前谢谢!
答案 0 :(得分:1)
只需更改您的代码
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);
}
收件人
Rational aspectRatio = new Rational(3, 4);
PictureInPictureParams params = new PictureInPictureParams.Builder()
.setAspectRatio(aspectRatio).build();
enterPictureInPictureMode(params);