Android:了解可绘制文件夹
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10517389/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android : Understanding drawable folder
提问by SANDHYA
I have an image with dimensions 250*70 pixels under drawable
folder (I'm just starting out in Android development, so i created drawable
folder in res
) and I have the same image with higher dimensions in drawable-large
folder; but the image is not looking as I expected.
我在drawable
文件夹下有一个尺寸为 250*70 像素的图像(我刚刚开始进行 Android 开发,所以我在 中创建了drawable
文件夹res
)并且我在drawable-large
文件夹中有更高尺寸的相同图像;但图像并不像我预期的那样。
Can anyone explain the reason behind/purpose of 3 drawable folders?
谁能解释 3 个可绘制文件夹背后的原因/目的?
Where should I store my image so that it displays properly in both modes (landscape & portrait) and in all the mobiles (including tablets)?
我应该在哪里存储我的图像,以便它在两种模式(横向和纵向)和所有手机(包括平板电脑)中都能正确显示?
I want my image to scale dynamically to the size of the device screen.
我希望我的图像动态缩放到设备屏幕的大小。
Can anyone share your views or links to search ?
任何人都可以分享您的观点或搜索链接吗?
采纳答案by user1160020
By default Android maintain three folders for the images with different resolution reason behind it is the use or the resolution of the Android Device on which the application gonna execute.
默认情况下,Android 为具有不同分辨率的图像维护三个文件夹,其背后的原因是应用程序将在其上执行的 Android 设备的使用或分辨率。
hdpi image folder maintain images for the Android Broad Screen set or Android Phones with the Higher resolution.
hdpi 图像文件夹维护 Android 宽屏集或具有更高分辨率的 Android 手机的图像。
ldpi for Lower images quality which supports by the earlier sets of the android
ldpi 用于较低的图像质量,由早期的 android 支持
mdpi for medium images support xhdi images folder for devices with maximum resolution.
中等图像的 mdpi 支持具有最大分辨率的设备的 xhdi 图像文件夹。
Android OS select the image it self by checking the compatible device and its resolution.
Android 操作系统通过检查兼容设备及其分辨率来自行选择图像。
Hope it helps. Accept if you get your explanation.
希望能帮助到你。如果您得到解释,请接受。
回答by Ian Warwick
The folder names need to be :
文件夹名称必须是:
- /drawable-ldpi For low density screens
- /drawable-mdpi For medium density screens
- /drawable-hdpi For high resolution screens
- /drawable-xhdpi For extra high resolution screens
- /drawable-ldpi 对于低密度屏幕
- /drawable-mdpi 用于中等密度屏幕
- /drawable-hdpi 对于高分辨率屏幕
- /drawable-xhdpi 用于超高分辨率屏幕
/drawable should be reserved for assets that you either (1) don't care about which device or for (2) xml drawable assets
/drawable 应该保留给您 (1) 不关心哪个设备或 (2) xml drawable 资产的资产
Then on top of that you can provide different resources based on configuration by using config qualifiers, you can read all about it here http://developer.android.com/guide/topics/resources/providing-resources.html
然后最重要的是,您可以使用配置限定符根据配置提供不同的资源,您可以在此处阅读所有相关信息http://developer.android.com/guide/topics/resources/providing-resources.html
for instance, you can have high resolution assets for landscape with a folder
例如,您可以使用文件夹为横向拥有高分辨率资产
- /drawable-land-hdpi
- /drawable-land-hdpi
Hope that helps
希望有帮助
回答by Sakthimuthiah
drawable-ldpi
drawable-ldpi
drawable-mdpi
drawable-mdpi
drawable-hdpi
drawable-hdpi
drawable-xhdpi
drawable-xhdpi
drawable-tvdpi
drawable-tvdpi
drawable-nodpi
drawable-nodpi
drawable-xxhdpi
drawable-xxhdpi
drawable-xxxhdpi
drawable-xxxhdpi
We can also use "drawable-xxhdpi"
xxhdpi (480dpi, Android 4.1 or later)
Refer "Android Tabular Column" in the following link
请参阅以下链接中的“Android 表格列”
http://en.wikipedia.org/wiki/Smartphone
http://en.wikipedia.org/wiki/Smartphone
Please refer "Table 1" in the following link (xxxhdpi)
请参考以下链接中的“表1”(xxxhdpi)
http://developer.android.com/guide/practices/screens_support.html#xxxhdpi-note
http://developer.android.com/guide/practices/screens_support.html#xxxhdpi-note
Note: the drawable-xxxhdpi qualifier is necessary only to provide a launcher icon that can appear larger than usual on an xxhdpi device. You do not need to provide xxxhdpi assets for all your app's images.
注意:drawable-xxxhdpi 限定符仅用于提供在 xxhdpi 设备上看起来比平常大的启动器图标。您不需要为所有应用程序的图像提供 xxxhdpi 资产。
Note will be in the following link http://developer.android.com/design/style/iconography.html#xxxhdpi-launcher
注意将在以下链接 http://developer.android.com/design/style/iconography.html#xxxhdpi-launcher
回答by OguzOzkeroglu
You should use drawable-hdpi
folder instead of drawable-large
.
您应该使用drawable-hdpi
文件夹而不是drawable-large
.
Also Supporting Multiple Screenspage may be helpful for you
也支持多屏幕页面可能对你有帮助
回答by mihail
actually there are 4 screen resolution standards - check this link for more information http://developer.android.com/guide/practices/screens_support.html, the table below. When you install your app on device, the device return one of these standards and pick the resources from the corresponding folder - ldpi, mdpi, hdpi and xhdpi
实际上有 4 个屏幕分辨率标准 - 查看此链接以获取更多信息http://developer.android.com/guide/practices/screens_support.html,下表。当你在设备上安装你的应用程序时,设备会返回这些标准之一并从相应的文件夹中选择资源 - ldpi、mdpi、hdpi 和 xhdpi
回答by Maksym
1) The reason behind the different drawable folders - to enhance user experience when using our app, by accomodating each device's screen density.
1) 不同可绘制文件夹背后的原因 - 通过适应每个设备的屏幕密度来增强使用我们的应用程序时的用户体验。
2) "Where should I store ..." - ideally, you store an image with the appropriate size for each screen density that exist. If you are a beginner, just use one folder and don't worry about it now.
2)“我应该在哪里存储......” - 理想情况下,您为存在的每个屏幕密度存储具有适当大小的图像。如果您是初学者,只需使用一个文件夹,现在不用担心。
4) Image scaling Here's a cool guide that helps you with image scaling inside the app: https://thoughtbot.com/blog/android-imageview-scaletype-a-visual-guide
4)图像缩放这是一个很酷的指南,可帮助您在应用程序内进行图像缩放:https: //thoughtbot.com/blog/android-imageview-scaletype-a-visual-guide
3) Links: https://material.io/tools/devices/- list of all devices and densities
3) 链接:https: //material.io/tools/devices/- 所有设备和密度的列表