独立图形不同的分辨率,机器人 [英] Separate graphics for different resolutions, android

查看:159
本文介绍了独立图形不同的分辨率,机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要为不同的分辨率可绘制资源,如小320x480,800x480的,854×480,800×600 1024×600,1024×768,1024x800。这是一个游戏和位图的比例是不能接受的,怎么把它们是非常敏感的。 DPI有关文件夹和屏幕尺寸(这是德precated但没有其他的方法来设置绘制的大屏幕,相同的分辨率和differend dpi)的组合不ena​​ugh。如何辨别显卡的1024×600和1024×768的例子吗?

I need drawable resources for different resolutions, such as 320x480, 800x480, 854x480, 800x600 1024x600, 1024x768, 1024x800. It is a game and the scaling of bitmaps is inacceptable, coz they are very sensitive to it. dpi dependent folders and combination with screen sizes(which are deprecated but no other way to set drawable for large screens with same resolution and differend dpi) are not enaugh. How to distinguish graphics for 1024x600 and 1024x768 for example?

这是很可悲的,停止自动捡资源和资产转换到手动加载使用的机制。 任何想法?

It is so sad to stop use mechanism of auto picking resources and switching to manual loading from assets. any ideas?

推荐答案

如果你想有一个像素完美贴合你总是可以通过一个简单的方法加载后台运行时:

If you want a pixel perfect fit you could always load the background at runtime via a simple method:

private void setBackgroundImage() {
   DisplayMetrics dm = getResources().getDisplayMetrics();
   int screenWidth = dm.widthPixels;
   int screenHeight = dm.heightPixels;

   // TODO: Conditional Structure to apply the right drawable 
   // ressource to be applied in the background

}

在你已经获得了显示器的分辨率,你可以申请通过<一个合适的背景href="http://developer.android.com/reference/android/view/Window.html#setBackgroundDrawableResource%28int%29"相对=nofollow> setBackgroundDrawable 的方法。

After you've acquired the resolution of the display you can apply the appropriate background via the setBackgroundDrawable method.

这篇关于独立图形不同的分辨率,机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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