Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/190.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何配置android emulator以匹配实际设备';谁的屏幕?_Android_Screen_Emulation - Fatal编程技术网

如何配置android emulator以匹配实际设备';谁的屏幕?

如何配置android emulator以匹配实际设备';谁的屏幕?,android,screen,emulation,Android,Screen,Emulation,这个问题与:,其中我能够通过试错将emulator的屏幕与实际设备相匹配。现在,我正试图找到一个公式来为其他设备实现同样的效果 我正在查看以下程序分别返回的数据配置和DisplayMetrics: activity.getResources().getConfiguration().toString(); ... DisplayMetrics displayMetrics = new DisplayMetrics(); activity.getWindowManager().getDefault

这个问题与:,其中我能够通过试错将emulator的屏幕与实际设备相匹配。现在,我正试图找到一个公式来为其他设备实现同样的效果

我正在查看以下程序分别返回的数据配置和DisplayMetrics:

activity.getResources().getConfiguration().toString();
...
DisplayMetrics displayMetrics = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
displayMetrics.toString();
对于所讨论的手机OnePlust 6T,屏幕规格为:6.41英寸,2340 x 1080像素,上面的输出为(设备):

配置{1.0 0 0 452mcc4mnc[en_US,pl_pl]ldltr sw411dpw411dp h812dp420dpi nrml长hdr宽CG端口夜力暗=0指 -keyb/v/h-nav/hwinconfig={mBounds=Rect(0,0-10802340)mAppBounds=Rect(0,80-10802214)mWindows模式=全屏 mDisplayWindowingMode=全屏mActivityType=标准 mAlwaysOnTop=未定义的旋转=旋转_0}s.1}

DisplayMetrics{密度=2.625,宽度=1080,高度=2134, 标度密度=2.625,xdpi=403.411,ydpi=409.903}

当emulator配置为与设备相同的规格时,输出为(EmuDev):

配置{1.0 310mcc260mnc[en_US]ldltr sw360dpw360dp h708dp480dpi nrml长端口指qwerty/v/v-nav/h winConfig={mBounds=Rect(0,0-1080,2196)mAppBounds=Rect(0,0-1080,2196)mWindowingMode=全屏mActivityType=standard}}}s.6}

DisplayMetrics{密度=3.0,宽度=1080,高度=2196,标度密度=3.0,xdpi=480.0,ydpi=480.0}

最后,我修改后的emulator的输出(设置为6.41 in和2643 x 1220)是(EmuMod):

配置{1.0 310mcc260mnc[en_US]ldltr sw406dpw406dp h809dp480dpi nrml长端口指针qwerty/v/v-nav/h winConfig={mBounds=Rect(0,0-12202499)mAppBounds=Rect(0,0-12202499)mWindowingMode=全屏mActivityType=standard}}}s.6}

DisplayMetrics{密度=3.0,宽度=1220,高度=2499,标度密度=3.0,xdpi=480.0,ydpi=480.0}

我的第一个猜测是,为了使emulator的屏幕与设备的屏幕相匹配,我必须从配置中匹配它们的dpwidth和h8(参见上面的bold),并得出以下公式:

EmuDev Density / Device Density * Spec Pixels = EmuMod Pixels
插入实际数字似乎证实了这一点:

3.0 / 2.625 * 2340 = 2674 ( ~ 2643 )
3.0 / 2.625 * 1080 = 1234 ( ~ 1220 )
然而,将这个公式应用到其他设备上并不起作用,因为模拟器的屏幕没有镜像设备的屏幕。关于如何调整它有什么想法吗?还需要寻找哪些其他指标

为完整起见,以下是它不工作的设备的输出,规格为6.3英寸,1080 x 2220像素的Galaxy A9:

设备:

配置{1.1 452mcc1mnc[vi_VN]ldltr sw360dpw360dp h668dp480dpi nrml长端口夜指键B/v/h-nav/h winConfig:{mBounds:Rect(0,0-10802220)mAppBounds:Rect(0,0-10802076)MWINDOWNGMODE:全屏显示窗口模式:全屏显示窗口类型:标准MalwaysTop:未定义旋转:旋转}s.1基站:0 ff:0 bf:0主题:0}

DisplayMetrics{密度:3.0,宽度:1080,高度:2076,标度密度:3.0,xdpi:409.432,ydpi:408.608}

EmuDev:

配置{1.0 310mcc260mnc[en_US]ldltr sw540dpw540dp h1038dp320dpi lrg长端口指qwerty/v/v-nav/h winConfig={mBounds=Rect(0,0-10802220)mAppBounds=Rect(0,0-10802124)mWindowingMode=全屏显示窗口模式=全屏显示模式=标准mAlwaysOnTop=未定义旋转=旋转}.1}

DisplayMetrics{密度=2.0,宽度=1080,高度=2124,标度密度=2.0,xdpi=320.0,ydpi=320.0}

和EmuMod(经修改的规格为720 x 1480):

配置{1.0 310mcc260mnc[en_US]ldltr sw480dpw480dp h914dp240dpi lrg长端口指qwerty/v/v-nav/h winConfig={mBounds=Rect(0,0-720,1480)mAppBounds=Rect(0,0-720,1408)mWindowingMode=全屏显示窗口模式=全屏显示模式=标准mAlwaysOnTop=未定义旋转=旋转}.1}

DisplayMetrics{密度=1.5,宽度=720,高度=1408,标度密度=1.5,xdpi=240.0,ydpi=240.0}