我正在写一个游戏,我想在中密度和高密度(320x480和480x800)上运行。为了在这两种密度下运行应用程序,我必须像这样设置support-screen param。
<supports-screens android:anyDensity="true" />我的问题是,在一些第二代设备(即HTC Desire)中,游戏运行在hd密度上,但性能有点差,所以我试图为这些设备“强制”中等密度。
我设法得到了像这样的电流密度。
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);DisplayMetrics类似乎有一个“setTo”方法,但不确定它是否适合我的需要,也不确定我应该如何使用它。有什么方法可以做到这一点吗?
谢谢!
发布于 2011-11-03 12:18:27
我不太清楚,但你可以试试这个:
只需使用全屏布局,并在内部定义另一个布局,具有您想要的大小。有点像这样:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:layout_width="200dip"
android:layout_height="150dip">
<Button android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>我在那里放了一个按钮,只是为了显示内容的位置。
谢谢
https://stackoverflow.com/questions/7988289
复制相似问题