本文介绍了如何使用资源预选赛上的布局,以区分喜欢的HTC Desire和三星GALAXY Nexus智能手机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做几个布局应用到目标的几个设备,如智能手机和平板电脑。

I make an application with several layouts to target several devices like smartphones and tablets.

有关的那一刻,我有以下文件夹来区分论点设备:

For the moment, I have the following folder to distinguish theses devices :

  • RES /布局#像三星GALAXY Nexus,S正常设备三,...
  • RES /布局大#为平板电脑7寸Android上< 3.2
  • RES /布局sw600dp#为平板电脑7寸
  • RES /布局XLARGE#为平板电脑10寸Android上< 3.2
  • RES /布局sw720dp#为平板电脑10寸
  • res/layout # for normal devices like Samsung Galaxy Nexus, SIII, ...
  • res/layout-large # for tablet 7 inch on Android < 3.2
  • res/layout-sw600dp # for tablet 7 inch
  • res/layout-xlarge # for tablet 10 inch on Android < 3.2
  • res/layout-sw720dp # for tablet 10 inch

解决方案是好的,但我有旧的智能手机如HTC欲望仍处于Android 2.2或2.3的一个问题。

The solution is good but I have a problem with old smartphones like HTC Desire that are still in Android 2.2 or 2.3.

其屏幕尺寸类是正常的,密度华电国际所以三星Galaxy Nexus的例如在预选赛资源的任何差异。

Their screen size category is normal and density is hdpi so there is any difference with Samsung Galaxy Nexus for example in qualifiers in resources.

随着版本的Andr​​oid 2.2或2.3,我不能用新的资源预选赛屏幕尺寸。所以,我不知道我怎么能专门针对这些设备预选赛有智能手机之间的不同的布局与屏幕是4英寸的多与别人认为是屏幕小于4英寸。

As version of Android is 2.2 or 2.3, I can't use new resources qualifiers for screen size. So, I don't know how I can target specifically these devices with qualifiers to have different layouts between Smartphones with screens that are 4 inch and more and with others that are screens with less than 4 inch.

什么人有一个解决方案,任何想法?

Someone has any idea about a solution ?

由于被提前。

维尔托德。

推荐答案

在提供几个布局的几点

  • 不要根据具体设备区分开资源文件夹。该少的文件夹,你做,越破越好...
  • 在其决议设备比较时也有比较它们的大小(例如一个是的Nexus 7的的Nexus 7 的有一个解决的 1280 *800 和其他类似的7英寸平板电脑一样的三星Galaxy Tab 的有分辨率 1024 * 600 )。
  • Dont distinguish resource folders according to specific devices. Theless folders you make, more the better...
  • Compare devices with their resolutions too when comparing withtheir sizes(One e.g is Nexus 7. Nexus 7 have a resolution of 1280 *800 and other similar 7 inch tablets like Samsung Galaxy Tab haveresolution of 1024 * 600).

更好的做法是把下面的可绘制

The better practice is to put the following drawables

// for Phones
drawable-ldpi
drawable-mdpi
drawable-hdpi
drawable-xhdpi

//for 7 inch tablets
drawable-large-mdpi
drawable-large-hdpi(for Nexus 7)

// for 10 inch tablets
drawable-xlarge-mdpi

给予支持,在Android平板电脑是一个地狱的工作IMO。因为有这么多的设备,并各自有各自的决议和密度。您无法定位的所有设备。

Giving support to tablets in Android is a hell job IMO. Because there are so many devices and each have their own resolutions and densities. You can't target all the devices.

的Nexus 7的情况下:虽然Nexus的7是一款7英寸的平板电脑,它具有的 1280 * 800 的决议。所以这是一个华电国际设备。但是,正常的7英寸设备具有较低分辨率的 1024 * 600 。因此,他们是 MDPI 设备和绘制预选赛可以改变。 (从我自己的经验,先放一个文件夹绘制-大MDPI 7英寸设备,并检查它的Nexus 7,如果有图像没问题,你没有把另一个文件夹,因为如果一个特定的文件夹不是present,Android将检查与最近的文件夹,并优化它的设备屏幕)。

Nexus 7 case: Even though Nexus 7 is a 7 inch tablet, it has resolution of 1280 * 800. So it's an hdpi device. But normal 7 inch devices have lower resolutions of 1024 * 600. So they are mdpi devices and the drawable qualifier can change. (From my own experience, first put a folder drawable-large-mdpi for 7 inch devices and check it on Nexus 7. If there is no problem with images, you dont have to put another folder. Because if a particular folder is not present, Android will check for the nearest possible folder and optimize it for the device screen).

现在与为有问题的布局-SW&LT;&GT; DP 属性是

Now the problem with giving layout-sw<>dp attribute are

  • 只有在API级别13加入所以不能支持更早的设备。
  • 由于它的高precedence在预选赛名单,我们不能给其他布局开始降低precedence预选赛。因为机器人始终以较高的precedence第一属性。
  • Only added in API Level 13. So can't support earlier devices.
  • Because of its high precedence in qualifier list, we can't giveother layouts starting with lower precedence qualifiers. BecauseAndroid always take higher precedence attributes first.

这篇关于如何使用资源预选赛上的布局,以区分喜欢的HTC Desire和三星GALAXY Nexus智能手机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-19 00:19