Snake
Snake

Reputation: 14648

Two devices, similar densities yet different image sizes?

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


}

Upvotes: 0

Views: 1163

Answers (4)

Shreyash Mahajan
Shreyash Mahajan

Reputation: 23596

I am not sure but the One Solution that i come to know base on your issue is, You have to made the layout as per the Device Screen Resolution.

As like,

Galaxy SII Support layout-normal-hdpi

As like,

Maybe HTC amaze support layout-large Screen.

So try to make the Layout as per the Device and it will solved your issue.

Hope it will help You.

Other detail that same to your question is here: android-layout-issue-for-htc-evo-3d

Enjoy Coding. . . . :)

Upvotes: 0

Glenn Bech
Glenn Bech

Reputation: 6182

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.

Upvotes: 2

Rohan Prabhu
Rohan Prabhu

Reputation: 7302

Would this be related to this issue: https://groups.google.com/forum/?fromgroups#!topic/android-developers/g56jV0Hora0

Upvotes: 0

Ray
Ray

Reputation: 429

The xdpi and ydpi on HTC is very high thats why the image is smaller.

I remember there was a bug that the reported xdpi and ydpi was totaly wrong, and to be honest they look wrong.

Upvotes: 0

Related Questions