简体   繁体   English

支持不同android屏幕尺寸和密度的技术

[英]Techniques in supporting different android screen sizes and densities

I am creating an android app and I want to be able to support as many android devices as possible that use Android 4.4 and above. 我正在创建一个android应用,我希望能够支持尽可能多的使用Android 4.4及更高版本的android设备。 The screen sizes that I want to support are: 我要支持的屏幕尺寸是:

  • Normal 正常
  • Large
  • xLarge

I have created different dimens.xml files for each size. 我为每种尺寸创建了不同的dimens.xml文件。 My first question is, the numbers that I put in each dimens.xml file should be based on the minimum dimension of each category? 我的第一个问题是,我在每个dimens.xml文件中放置的数字应基于每个类别的最小尺寸? For example: for normal I should design the layout in a device with dimension 470dp x 320dp, for large a device with dimensions 640dp x 480dp and for xlarge a device with dimensions 960dp x 720dp ? 例如:对于正常情况,我应该在尺寸为470dp x 320dp的设备中设计布局,对于大型的尺寸为640dp x 480dp的设备,对于xlarge的尺寸为960dp x 720dp的设备设计布局?

My second questions is, let's say that we have our base dimension files for normal, large and xlarge, how many more dimension xml files should I create in order to support different densities too. 我的第二个问题是,假设我们有普通,大和xlarge的基本尺寸文件,还应该创建更多尺寸的xml文件以支持不同的密度。 Also do devices with Android 4.4 and above support all densities or are some excluded? 具有Android 4.4及更高版本的设备是否也支持所有密度? (for example LDPI) (例如LDPI)

Now let's say that I exclude the LDPI density, should I make each density for each size or if I make one MDPI for each screen size and one HDPI for each screen size everything will "look" the way I want them, even in devices with XXXHDPI density? 现在让我们说我不包括LDPI密度,应该为每种尺寸设置每种密度,还是为每种屏幕尺寸设置一个MDPI,为每种屏幕尺寸设置一个HDPI,即使在具有XXXHDPI密度?

One last thing, if you can recommend any devices to make my "base" layout that would be great. 最后一件事,如果您可以推荐任何设备来制作我的“基本”版面,那就太好了。

hi you can handle size of different resolutions by this, 嗨,您可以以此来处理不同分辨率的尺寸,

create different types of values folder.Create these folder inside res. 创建不同类型的value文件夹。在res中创建这些文件夹。

values-hdpi 值-hdpi

values-xhdpi 值-xhdpi

values-xxhdpi 值-xxhdpi

values-xxxhdpi 值-xxxhdpi

and dimens.xml create accordingly for different resolutions.Use all padding and margin from here. 和dimens.xml分别为不同的分辨率创建。从此处使用所有填充和边距。

This is way to handle different resolutions for different sizes. 这是处理不同尺寸的不同分辨率的方法。

for more info see the below 有关更多信息,请参见下面 图片 .

for more details take a look from my project base structure 有关更多详细信息,请查看我的项目基础结构

Thanks 谢谢

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

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