且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

两款器件,密度相近但不同的图像大小?

更新时间:2022-10-17 17:24:33

答案中的数字就在你的面前。

源代码的http://www.androidauthority.com/htc-amaze-4g-vs-samsung-galaxy-s-ii-t-mobile-27110/


  

在屏幕大小而言,三星Galaxy S2具有一个稍大
  屏幕显示4.52英寸。宏达惊奇4G,另一方面
  另一方面,带有大小与国际同类变种的屏幕
  银河S2-4.3英寸。


块引用>

宏达惊奇具有更高的分辨率和更小的物理屏幕。这导致了更高的像素密度 - 这意味着较小的物理像素,因为需要被塞进一个更紧地方他们更大数目。

的例如2​​40x160因此将出现在惊奇

小的图像

对于S2所报告的DPI值,显然是错误的。根据度量定它是'
一百六十○分之八百= 5英寸,长边,并在短边一百六十零分之四百八十〇= 3英寸。
这将给予的sqrt(5 * 5 + 3 * 3)= 5,8英寸的屏幕尺寸。

对于惊奇的DPI值是正确的。正如我们看到的,如果我们做一个简单的毕达哥拉斯。 SQRT(二百五十八分之九百六十零^ 2 +二百五十六分之五百四十^ 2)= 4,27

作为一个开发者从我的测试设备HTC轰动移动,当我遇到同样的事情,和S2。

Ok here is a problem that is puzzelling me that I really would like you to help me out with. I am testing my app with both HTC amaze and Galaxy S2 (as I know both are High density) and both in the 3.7-4.3 screen range

The problem is that the same image looks different in terms of size on both screens. On The HTC amaze it is much smaller. I have my 3 drawable folders with the appropriate different sizes ( which I should need anyways here because both devices are of the same density)

I did some debugging on the DisplayMatrics and I found for HTC amaze the follows:

density 1.5
desnityDPI 240
Height pixels:540
Width pixels:960
xdpi 258
ydpi 256

However, for the S2 galaxy the display metrics are:

density 1.5
desnityDPI 240
Height pixels:480
Width pixels:800
xdpi 160
ydpi 160

So can someone explain to me why the images sizes on both devices are different. On HTC amaze images are much smaller than on the S2? Thank you

Edit: Code used to get the DP info is

DisplayMetrics mt =getApplicationContext().getResources().getDisplayMetrics();

EDIT:

<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);


}

The answer is in the numbers right in front of you.

Source http://www.androidauthority.com/htc-amaze-4g-vs-samsung-galaxy-s-ii-t-mobile-27110/

In terms of screen size, the Samsung Galaxy S2 has a slightly larger screen with 4.52 inches of display. The HTC Amaze 4G, on the other hand, comes with a screen similar in size to the international variant of the Galaxy S2–4.3 inches.

The HTC Amaze has a higher resolution, and a smaller physical screen. This results in a higher pixel density- that means smaller physical pixels, because a larger number of them needs to be crammed into a tighter place.

An image of for example 240x160 would therefore appear smaller on the Amaze.

The reported DPI values for the S2 is clearly wrong. According to the metrics given it is ' 800/ 160 = 5 inches on the long side, and 480/160 = 3 inches on the short side. This would have given a screen size of sqrt (5 * 5 + 3*3 ) = 5,8 inches.

The DPI values for The amaze is correct. As we see if we do a simple pythagoras. Sqrt (960/258^2 + 540/256^2) = 4,27"

As a developer I experience the same thing when moving from my test device HTC sensation, and the S2.