简体   繁体   English

Android虚拟设备检测到错误的屏幕尺寸

[英]Android Virtual Device detects wrong screen size

I have been working with programmatic layout in Android Studio and i have a problem: 我一直在使用Android Studio中的程序化布局,但遇到了一个问题:

  • AVD always uses normal layout even if i use Nexus 7 which has "large" screen as its property 即使我使用具有“大”屏幕的Nexus 7,AVD也始终使用常规布局
  • it is not code problem, since when i plug in my tablet it uses large layout and works fine 这不是代码问题,因为当我插入平板电脑时,它使用的是大版面并且效果很好

Any ideas where the problem might come from? 有什么问题可能出在哪里?

Well you are right in some sense android should take layout dependent on different densities but some mobile do not fall under specific density. 好吧,从某种意义上来说,您是正确的,Android应该根据不同的密度进行布局,但是某些移动设备不属于特定的密度。 Therefore android will pick up default layout from layout directory. 因此,Android将从布局目录中选取默认布局。

to support multiple screen resolution provide different layout for different screen sizes, you can make following directories in res directory like this 为了支持多种屏幕分辨率,为不同的屏幕尺寸提供不同的布局,您可以在res目录中创建以下目录,如下所示

layout-hdpi

layout-mdpi

layout-xhdpi

layout-xxhdpi

layout-w320dp-h408dp

layout-w480dp-h800dp


layout-w480dp-h854dp

layout-w720dp-h1280dp

layout-w1080dp-h1920dp

layout-w1440dp-h2560dp

when you provide layout in all this directories you will give multiple screen support for different sizes as well 当您在所有这些目录中提供布局时,您还将为不同尺寸提供多屏支持

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM