有关 Android 的可绘制文件夹的问题
亲爱的 StackOverflow 用户,
我在 StackOverflow 上找到了有关使用哪些 Drawable(HDPI、MDPI、LDPI)的信息。目前我只使用 HDPI 文件夹。我的图像按钮是 72x72。根据 Eclipse,查看 .XML 文件的图形布局,最小的屏幕(2.7 IN QVGA)可以显示所有按钮。
如果我没猜错的话,如果有 MDPI 或 LDPI 屏幕的人使用该应用程序,Android 会缩小图像,对吧?是否还有一个设置,其中所有不同的 DPI 尺寸都使用 72x72 图像?我应该在 Android 清单中具体定义支持哪些 DPI 吗?或者当我将其留空时,它会支持所有可能的设备吗?
预先感谢您的任何答复! (也许这些问题的(部分)已经得到解答,但是谷歌找到了很多与此相关的内容)
编辑:
我为我的 android 清单文件找到了这个。这会使其适用于所有设备吗?并缩小 HDPI 图像?:
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"
android:resizeable="true" />
Dear StackOverflow users,
I found a of information about what Drawables to use (HDPI, MDPI, LDPI) on StackOverflow. Currently I am using only the HDPI folder. My ImageButtons are 72x72. According to Eclipse, looking at the Graphical Layout of the .XML file, the smallest screen (2.7 IN QVGA) can show all buttons.
If I am correct, Android will scale down the images if someone with MDPI or LDPI screen uses the APP, right? Is there also a setting wherein all different DPI sizes use the 72x72 image? And should I specifically define in the Android Manifest what DPI's are supported? Or when I leave this empty, will it support all possible devices?
Thanks in advance for any answers!
(Maybe (parts) of these questions are already answered, but there is so much stuff found by google regarding this)
EDIT:
I found this for my android manifest file. Would this make it work on all devices? And scale down the HDPI images?:
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"
android:resizeable="true" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的。
如果将它们放在
res/drawable/
而不是res/drawable-hdpi/
中,应该会产生这种效果。如果您希望阻止您的应用程序出现在特定密度的市场中,您可以使用
<兼容屏幕>
来实现。理想情况下,您的应用程序可以在所有密度下运行。它将允许您的应用程序安装在所有设备上。它是否有效取决于你。请删除
android:resizeable
属性(已弃用)。您还可以删除android:anyDensity
(默认情况下为true
)。是的,它应该缩小 HDPI 图像。即使没有这个元素它也会这样做。
Yes.
It should have that effect if you put them in
res/drawable/
rather thanres/drawable-hdpi/
.If you wish to preclude your application from appearing in the Market for certain densities, you can use
<compatible-screens>
for that. Ideally, you have your app work on all densities.It will allow your app to be installed on all devices. Whether or not it works is up to you. Please remove the
android:resizeable
attribute (deprecated). You can also removeandroid:anyDensity
(it istrue
by default).Yes, it should scale down the HDPI images. It would do that even without this element.
如果您只使用一种尺寸,我会将图像放在drawable文件夹中,而不是drawable-hdpi / ldpi / xhdpi中。这样,除非其他屏幕分辨率特定文件夹中存在可用的特定图像,否则始终使用该文件夹中的图像。
我不太确定你的意思
当您将所有内容放入标准可绘制文件夹中时,Android 将始终使用此图像。如果您将图像的宽度设置为 dp(密度独立像素)而不是普通像素,它将根据用户的屏幕密度自动缩小图像。查看来自 Google 的此链接以支持多个屏幕具有与密度无关的应用。
将其留空,它将支持所有可能的设备。
不,不会,将其排除。只需使用与密度无关的像素来适应您的图像,它们就会在您的应用程序中进行缩放和使用。
If you only use one size, I would put the images in the drawable folder, not drawable-hdpi/ldpi/xhdpi. In that way, the image in that folder is always used unless there is a specific one available in the other screen resolution specific folders.
I'm not exactly sure what you mean by
When you put everything in the standard drawable folder, android will always use this image. If you set the width of an image in dp (density independent pixels) instead of plain pixels, it will automatically scale down the image according to the screen density of the user. Take a look at this link from Google to support multiple screens and have a density-independent application.
Leave it empty, it will support all possible devices.
No it won't, leave it out. Just use density-independent pixels to fit your images and they will be scaled and used fine in your application.