支持不同屏幕

Supporting Different Screens

我正在为 android 支持不同的屏幕 我创建了不同的可绘制文件夹并根据他们的要求粘贴图片,如下所示

drawable-ldpi = 240*320 px (dimension)
drawable-mdpi = 320*480px
drawable-hdpi = 480 * 800px
drawable-xhdpi=720*1280px

然后我将布局复制粘贴到相应的布局文件夹中,例如

layout-small
layout-normal 
layout -land
layout-land-small

等等等等 现在当我打开每个文件夹的 activity_main(布局) 时,它必须 select 背景照片形成相应的 drawable 文件夹,但它 select 只有一张照片来自 drawable-hdpi布局。 哪里有问题???

它根据设备选择布局。它只为每个设备选择一种布局。例如,屏幕尺寸为 4.5 的 phone 选择普通布局,对于平板电脑则选择大尺寸布局。

These folders are for different devices with different screen sizes and resolution.

As you want all the images to display. You just cant because you device is static in screen size and resolution.

Save all the images in each folders you'll get all the images. This too gets displayed from one folder.

You gotta read developer site to understand better

Android OS 自动从特定文件夹中选择可绘制对象。 作为开发者,您只能为每个文件夹提供不同的可绘制对象:

drawable-xhdpi/
     awesomeimage.png
drawable-hdpi/
        awesomeimage.png
drawable-mdpi/
        awesomeimage.png
drawable-ldpi/
        awesomeimage.png

证明其有效的最佳方式是在真实设备上启动您的应用程序。 您还可以在 Android Studio 的设计器中使用不同的设备,并且应应用来自不同可绘制文件夹的图片:

希望对您有所帮助。

-ldpi、-mdpi、-hdpi、-xhdpi 与分辨率相关,-small、-normal 与尺寸相关,-land 与设备方向相关。您可以更改为:

layout-ldpi, 
layout-mdpi, 
layout-hdpi, 
layout-xhdpi

给他们select(订单)

drawable-ldpi = 240*320 px (dimension)
drawable-mdpi = 320*480px
drawable-hdpi = 480 * 800px
drawable-xhdpi=720*1280px