【发布时间】:2014-07-24 14:25:08
【问题描述】:
我尝试检查屏幕分辨率 我用谷歌搜索了一个例子,但我无法检查屏幕分辨率。我尝试检查 480X800 和 720X1280 屏幕分辨率
int screenSize = getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK;
switch (screenSize) {
case Configuration.SCREENLAYOUT_SIZE_LARGE:
mapimg.getLayoutParams().height = 400;
break;
case Configuration.SCREENLAYOUT_SIZE_NORMAL:
mapimg.getLayoutParams().height = 200;
break;
case Configuration.SCREENLAYOUT_SIZE_SMALL:
break;
default:
}
布局
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/relativeLayout1"
android:layout_alignParentLeft="true" >
<ImageView
android:id="@+id/mapimages"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<com.google.android.gms.maps.MapView
android:id="@+id/pointMap"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/mapimages"
class="com.google.android.gms.maps.MapFragment" >
</com.google.android.gms.maps.MapView>
</RelativeLayout>
这是我的代码 我尝试在相同的屏幕分辨率下我的 imageview 的高度会有所不同 480X800 高度 200 和 720X1280 400 当我在两个屏幕分辨率中运行程序时 imageview 有 200 高度 我究竟做错了什么?如果有人知道解决方案,请帮助我 谢谢
【问题讨论】:
-
如何为不同的分辨率使用不同的布局/尺寸而不是通过代码来实现...
-
@Selvin 提供了一个很好的解决方案:developer.android.com/samples/BasicSyncAdapter/res/values/…