开发Android高分辨率屏幕,但支持低分辨率屏幕 [英] Delveloping for Android high res screens, but supporting low res screens

查看:71
本文介绍了开发Android高分辨率屏幕,但支持低分辨率屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在为低分辨率屏幕 (320x480) 开发 Android 游戏,然后让 Android 处理密度调整,以便游戏在高分辨率屏幕上运行.它允许我保持我的 APK 文件的大小很小,而且我不必为我的游戏中的每个图像创建多个版本.它实际上运行良好,游戏在高分辨率屏幕上仍然看起来不错.

I've been developing Android games for the lower res screens (320x480) and then letting Android handle the density adjustments so the games work on high res screens. It allows me to keep the size of my APK files small and I don't have to create multiple versions of every image in my games. It actually works fine, the games still look nice on higher res screens.

然而,我的问题是,是否有可能做同样的事情,只是倒退?我可以为高分辨率屏幕 (800x480) 进行开发,然后以某种方式让 android 自动处理密度降低吗?

However, my question is, is it possible to do the same thing, only backwards? Can I develop for high res screens (800x480) and then somehow let android handle the density reductions automatically?

推荐答案

是的.

在您的 xml 布局中,使用尺寸的倾角值.

In your xml layouts, use dip values for sizes.

示例:

100dip =75 @ 120dpi100 @ 160dpi150 @ 240dpi

100dip = 75 @ 120dpi 100 @ 160dpi 150 @ 240dpi

如果您需要某些可绘制对象的更高分辨率资源,请使用...drawable-hdpidrawable-mdpidrawable-ldpi

if you need a higher res resource for certain drawables, use the... drawable-hdpi drawable-mdpi drawable-ldpi

应用程序将根据屏幕的密度使用来自正确资源文件夹的可绘制对象.

The app will use the drawable from the correct resource folder depending on the screen's density.

如果可以使用 FILL_PARENT 或 WRAP_CONTENT,请尽量不要在某些元素上使用绝对宽度和高度.

Try not to use absolute widths and heights on certain elements if you can use FILL_PARENT or WRAP_CONTENT.

这里有一些很好的提示:http://developer.android.com/guide/practices/screens_support.html

Here's some good tips: http://developer.android.com/guide/practices/screens_support.html

这篇关于开发Android高分辨率屏幕,但支持低分辨率屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆