不同高度的Andr​​oid设备采用相同的布局文件夹 [英] Android devices with different height takes same layout folder

查看:501
本文介绍了不同高度的Andr​​oid设备采用相同的布局文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个福邦AQ5000与屏幕分辨率 - 1280×720像素和摩托罗拉摩托摹XT1033,分辨率720×1280 pixels.I有一个布局文件夹命名布局sw360dp这是我专门为喜欢三星S4的设备,S3,福邦帆布等,但这款摩托罗拉设备也使用相同的布局,这将创建的扭曲,它显示的图像。

I have a Micromax AQ5000 with Screen Resolution- 1280*720 pixels and Motorola Moto G XT1033 with resolution 720 x 1280 pixels.I have a layout folder named layout-sw360dp which I designed for devices like Samsung s4,s3,Micromax canvas etc but this Motorola device is also using the same layout and this creates the images displayed as distorted in it.

我怎样才能创建一个文件夹为小型设备(MOTO G)我试图布局xhdpi,但它不工作,我怎么能与命名的高度和宽度的布局。

How can I create a folder for the small device(Moto g) I tried layout-xhdpi but it doesn't work how can I name layout with height and width.

推荐答案

嗯,你是对的在某种意义上机器人应该布局依赖于不同的密度,但有些手机不属于比重下降。因此,Android将拿起默认的布局从布局目录。

Well you are right in some sense android should take layout dependent on different densities but some mobile do not fall under specific density. Therefore android will pick up default layout from layout directory.

要支持多屏幕分辨率不同的屏幕大小提供不同的布局,可以使以下目录中这样的res目录

to support multiple screen resolution provide different layout for different screen sizes, you can make following directories in res directory like this

layout-hdpi

layout-mdpi

layout-xhdpi

layout-xxhdpi

layout-w320dp-h408dp

layout-w480dp-h800dp

layout-w480dp-h854dp

layout-w720dp-h1280dp

layout-w1080dp-h1920dp

当你在这一切的目录提供版面,你会给出不同尺寸的多屏支持,以及     布局w1440dp-h2560dp

when you provide layout in all this directories you will give multiple screen support for different sizes as well layout-w1440dp-h2560dp

使用浸,而不是他们会帮你调试你的布局,因为他们将尽量保持一致的尺寸,多种屏幕分辨率,

Use "dip" instead they will help you in debugging your layout as they will try to keep a coherent size to multiple screen resolutions,

<ImageView
            android:id="@+id/avtar_animation_11"
            android:layout_width="45dip"
            android:layout_height="45dip"
            android:src="@drawable/avtar011"/>

同时支持多屏的时候你给DP向规模化,其实Android的期待您提供不同的屏幕分辨率不同的值。比方说下面是你imagview尺寸使得在res文件夹几个文件夹在你这样的机器人项目下

while supporting multiple screen when you give "dp" to dimensions, Actually android expects you to provide different values for different screen resolution. Lets say below is your imagview dimensions make few folders in res folder in your android project like these below

values-hdpi, values-mdpi, values-ldpi, values-xhdpi, values-xxhdpi

和在其中做出 dimens.xml 文件中的每个人,写

and in them make a dimens.xml file each of them and write

<dimen name="image_view_width">28dp</dimen>
<dimen name="image_view_height">28dp</dimen>

现在,我已经提到的DP在这里,而不是浸机器人要我跟踪了不同尺寸不同的屏幕分辨率,所以我会改变image_view_width和image_view_height值是不同的价值观的文件夹,其中dimens.xml所在。确保你的DP值的变化,按您的屏幕分辨率您希望您的观点,以适应

now that i have mentioned "dp" here instead of dip android wants me to keep track for different dimensions for different screen resolution, So i will change the image_view_width and image_view_height values are in separate values folders where dimens.xml is located. Make sure your dp values change as per your screen resolution you want your view to fit in.

 <ImageView
        android:id="@+id/avtar_animation_11"
        android:layout_width="@dimen/image_view_width"
        android:layout_height="@dimen/image_view_height"
        android:src="@drawable/avtar011"/>

困难的部分已经结束,现在的Andr​​oid,这取决于将搭载dimens.xml值之一筛选你的应用程序正在运行,瞧现在你的布局岩

hard part is over now android will pick one of dimens.xml values depending on which screen your app is running, Voila now your layout rocks

这篇关于不同高度的Andr​​oid设备采用相同的布局文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆