如何在Android中调整PIP模式的大小 [英] How to resize PIP mode in android
本文介绍了如何在Android中调整PIP模式的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在我的应用中实现画中画模式.我正在PIP模式下实施Google地图,但无法调整全屏地图的大小.它始终缩放地图中心点.我已经完成了与此问题相关的RND,但未找到任何适当的答案.基本上,我需要在应用程序上实现类似Whatsapp app pip Screen之类的布局,该如何实现?我的代码在这里:
I'm trying to implement a picture-in-picture mode in my app. I'm Implementing google map on PIP mode but I can't resize the full-screen map. It always zooms on map center point. I have done RND related to this issue but not finding any proper answer. Basically, I need the layout like Whatsapp app pip Screen on my app how to implement? And my Code is here:
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"/>
在这段代码中,我的屏幕就像
In this code, I have the screen like
我想要
我该如何解决?
提前谢谢!
推荐答案
只需更改您的代码
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);
这篇关于如何在Android中调整PIP模式的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文