如何在android中支持不同的屏幕尺寸 [英] How to support different screen size in android
问题描述
我正在 android 中开发一个应用程序,我必须支持所有不同的屏幕尺寸和密度.所以我为布局创建了不同的文件夹:layout-small layout-large
和 layout
.
I'm developing an app in android and I have to support all different screen sizes and density. So i've created different folder for layout : layout-small layout-large
and layout
.
然后我为图像创建了不同的文件夹:ldpi、mdpi
和 hdpi
.在所有可绘制文件夹中,图像必须具有不同的大小,真的吗?请问这是因为我的手机屏幕尺寸大,密度中等,显示的图像会更小,而且它们的尺寸不正确?
Then I've created different folder for image: ldpi, mdpi
and hdpi
. In all drawable folder the image must be with different size true? I ask this cause of I have a phone with screen size large and density medium, the image shown will be smaller and they will not take the right size?
推荐答案
对于不同的屏幕尺寸,以下是一个应用程序中的资源目录列表,为不同的屏幕尺寸提供不同的布局设计,为小、中型提供不同的位图可绘制、高密度和超高密度屏幕.
For Different screen size, The following is a list of resource directories in an application that provides different layout designs for different screen sizes and different bitmap drawables for small, medium, high, and extra high density screens.
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density
Manifest 中的以下代码支持所有 dpi.
The following code in the Manifest supports all dpis.
<supports-screens android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
还可以查看我的SO 答案.
这篇关于如何在android中支持不同的屏幕尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!