【发布时间】:2012-05-09 19:39:21
【问题描述】:
好的,这是一个令我困惑的问题,我真的希望你能帮助我解决这个问题。 我正在使用 HTC amaze 和 Galaxy S2(据我所知都是高密度)和 3.7-4.3 屏幕范围测试我的应用
问题是同一张图片在两个屏幕上的尺寸看起来不同。在 HTC 惊奇它是小得多。我有 3 个不同大小的可绘制文件夹(无论如何我都应该在这里需要,因为两个设备的密度相同)
我在 DisplayMatrics 上做了一些调试,发现 HTC 惊奇如下:
density 1.5
desnityDPI 240
Height pixels:540
Width pixels:960
xdpi 258
ydpi 256
但是,对于 S2 星系,显示指标是:
density 1.5
desnityDPI 240
Height pixels:480
Width pixels:800
xdpi 160
ydpi 160
那么有人可以向我解释为什么两种设备上的图像尺寸不同。 HTC 惊奇图像比 S2 小得多? 谢谢
编辑:用于获取 DP 信息的代码是
DisplayMetrics mt =getApplicationContext().getResources().getDisplayMetrics();
编辑:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/carpet"
android:clipChildren="false"
android:clipToPadding="false"
android:keepScreenOn="true" >
<RelativeLayout
android:id="@+id/relativeLayoutBottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:clipChildren="false"
android:clipToPadding="false" >
<ImageView
android:id="@+id/ivBottom1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView
android:id="@+id/ivBottom2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp" />
<ImageView
android:id="@+id/ivBottom3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp" />
</RelativeLayout>
</RelativeLayout>
private void initialize(ArrayList<CardSuitNumber> cards) {
RelativeLayout flBottom = (RelativeLayout) findViewById(R.id.relativeLayoutBottom);
player1.clearAll();
for(int i=0; i<GameConstants.MAXRANKS;i++){
player1.addCard((ImageView)flBottom.getChildAt(i));
}
}
public void addCard(ImageView im){
Drawable drawable = card.getCardSuitNumber().getDrawable(mActivity);
im.setImageDrawable(drawable);
imsetVisibility(View.VISIBLE);
}
【问题讨论】:
-
你试过在 S2 上放一个新的 rom 吗?这两款手机的操作系统版本是什么?
-
新ROM?不知道这意味着什么,但我不这么认为。操作系统版本是 Galaxy 上的 android 2.3.5 和 HTC 上的 2.3.4
-
我曾经遇到的 S2 有一个问题,它从错误的资源文件夹中获取资源。要查看设备从哪个文件夹获取资源,您可以尝试以下操作:在不同资源文件夹中使用相同名称的不同图像,并检查哪个设备正在加载哪个。
-
cyanogenmod.com/devices/samsung-galaxy-s2,安装在 S2 上,然后重新运行测试以查看密度
-
我对 Vikram 进行了测试,两者都从高密度文件夹中提取... L7,问题不在于 S2。 HTC amaze 显示的图像比预期的要小..加上不想损坏 S2 手机:)