如何创建支持多种屏幕尺寸的android应用程序
我查看了一些指南和教程,但我的问题仍然存在。 我使用小图像来开发这个应用程序来创建按钮、文本和背景,并将其放在 res/drawable-ldpi 目录中。然后我在网上看到我必须按照这个比例制作图像: 3:4:6。因此,如果我的图像很小,要为中等屏幕尺寸创建它们,我必须采用小图像的尺寸和倍数为 4/3,对于大屏幕倍数为 6/3=2。 我在这里看到这些:提供资源。 现在,当我为普通屏幕(中)创建一些图像时,我启动屏幕密度为 160 或 200 的模拟器,但图像仍然保留在 ldpi 中使用的图像。 我能做些什么? 您能详细解释一下这些多屏幕的问题是什么以及如何解决这个问题吗? 这是我的 Android 清单的一部分:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="spazio.digitale.com" android:versionCode="1"
android:versionName="1.0" android:installLocation="auto"
android:screenOrientation="portrait"
>
<uses-sdk android:minSdkVersion="7" android:maxSdkVersion="11" />
<uses-permission android:name="android.permission.INTERNET" />
<supports-screens android:normalScreens="true"
android:smallScreens="true" android:largeScreens="true"
android:anyDensity="true" />
I look over some guide and tutorial but my problem still exists.
I develop this application using small image to create button, text and background and i put it in res/drawable-ldpi directory. Then i see on web that i have to make images with this proportion:
3:4:6. So if my images were small, to create them for medium screen size, i have to take dimension of small image and multiple for 4/3, and for large screen multiple for 6/3=2.
I see these here: Providing Resource.
Now when i create just some images for normal screen ( medium ) i launch emulator with screen density 160 or 200, but the image still remain that used in ldpi.
What can i do?
Can you explain me well what is the problem with these multiple screen and how to solve this?
This is a part of my android manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="spazio.digitale.com" android:versionCode="1"
android:versionName="1.0" android:installLocation="auto"
android:screenOrientation="portrait"
>
<uses-sdk android:minSdkVersion="7" android:maxSdkVersion="11" />
<uses-permission android:name="android.permission.INTERNET" />
<supports-screens android:normalScreens="true"
android:smallScreens="true" android:largeScreens="true"
android:anyDensity="true" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用像素比例来设计..
把这个放在清单中
use to pixels scale to design..
put this in manifest
对于按钮,使用 9-patch 工具创建图像。
For button, create images using 9-patch tool.
对于位图,经验法则是首先从最高密度开始,然后将其缩小,因为缩小位图总是比放大它们更容易。
另外,您似乎混淆了屏幕密度和屏幕尺寸。现在不用担心屏幕尺寸(除非你有一张背景图像占据整个屏幕尺寸,我对此表示怀疑)。不,您提到的比率与屏幕尺寸无关,仅适用于屏幕密度。首先解决密度问题。然后,一旦解决了这个问题,您就可以专注于确保布局适合尺寸。
甚至不用担心 ldpi,它只占手机市场的 0.2%。您只是在浪费时间来优化该密度。
With bitmaps, the rule of thumb is to start with the highest density first, and then scale it down, because it's always easier to scale down bitmaps than to scale them up.
Also, you seem to be confusing screen density with screen size. Do not worry about the screen size for now (unless you have one background image that takes the entire screen size, which I doubt). And no, the ratio you mentioned has nothing to do with screen sizes, that only applies to screen densities. Fix the density issue first and foremost. Then, once that's fixed, you can focus on making sure the layout fits the size.
And don't even bother with ldpi, that's only 0.2% of the market of handsets. You're just wasting your time optimizing for that density.