我的XML设计不工作在所有Android设备? [英] My Xml design not working in all android Devices?
问题描述
在我的项目,我的设计工作正常在我的Android HTC 2.3.4但在4.0.1我的屏幕没有显示完全(部分的设计是从底部切割)。为什么呢?
In my project, My Design is working fine in my android HTC 2.3.4 But on 4.0.1 my screen is not showing full ( Some design is cutting from Bottom). Why?
推荐答案
既然你还没有发布任何code,我只给你的Android布局和资源的简要概述。
Since you haven't posted any code, I'll just give you a brief overview of android layouts and resources.
您必须对您的应用程序创建多个资源。 Android有4决议(LDPI,MDPI,华电国际和xhdpi)和4个广义的屏幕尺寸(小,中,大号和特大号)。所以,你必须做出4的布局(或者3,如果你不打算支持平板电脑,因为平板电脑受到额外的大类)支持的屏幕尺寸。
You have to create multiple resources for your app. Android has 4 resolutions (ldpi,mdpi,hdpi and xhdpi) and 4 generalized screen sizes (small, medium, large and extra large). So you have to make 4 layouts (or 3 if you don't plan on supporting tablets, since tablets come under the extra large category) to support the screen sizes.
下面是一个一般指南:
把布局小型,中型,大型和你的RES特大型/文件夹,如下所示:
put layouts for small, medium, large and extra large in your res/ folder as follows:
res/layout/sample_layout.xml // default layout
res/layout-small/sample_layout.xml // layout for small screen size
res/layout-large/sample_layout.xml // layout for large screen size
res/layout-xlarge/sample_layout.xml // layout for extra large screen size
您也可以使用
RES /布局陆/ sample_layout.xml
的横向所有的屏幕尺寸,也可以针对景观布局特定的屏幕尺寸为水库/layout-medium-land/sample_layout.xml
res/layout-land/sample_layout.xml
for landscape orientation for all screen sizes or you can target landscape layouts for specific screen sizes as res/layout-medium-land/sample_layout.xml
请注意,所有的布局具有相同的名称。
note that all the layouts have the same name.
一旦你有你的布局准备好了,你需要照顾的形象也决议
once you have your layouts ready, you need to take care of image resolutions also
再次出现在你的资源/文件夹添加图片:
once again in your res/ folder add images like this:
res/drawable-ldpi/sample_image.png // low density
res/drawable-mdpi/sample_image.png // medium density
res/drawable-hdpi/sample_image.png // high density
res/drawable-xhdpi/sample_image.png // extra high density
再次,所有的图像具有相同的名称
once again, all the images have the same name.
有关图像设计的一般准则是:
general guidelines for designing images are:
ldpi is 0.75x dimensions of mdpi
hdpi is 1.5x dimensions of mdpi
xhdpi is 2x dimensinons of mdpi
一般,我设计MDPI图像分辨率320x480一个屏幕,然后乘以尺寸按上述规则来获得图像的其他决议。
generally, I design mdpi images for a 320x480 screen and then multiply the dimensions as per the above rules to get images for other resolutions.
Android将自动选择布局和图像根据设备的最佳组合。例如,对于一个高分辨率的中等大小的设备,布局中,高密度的图象将被显示给用户。
Android will automatically select the best combination of layout and image depending on the device. For example, for a high resolution medium size device, layout-medium and high density image will be displayed to the user.
请确保您创建仿真器所有这些组合,并彻底测试你的应用程序。下面是详细信息的官方文档:
Make sure you create emulators for all these combinations and test your app thoroughly. here's the official docs for more info:
<一个href="https://developer.android.com/guide/practices/screens_support.html">https://developer.android.com/guide/practices/screens_support.html
这篇关于我的XML设计不工作在所有Android设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!