0

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


}
Snake
  • 14,228
  • 27
  • 117
  • 250
  • did you try putting a new rom on the S2? what are the OS versions of both of the phones? – L7ColWinters Apr 30 '12 at 03:10
  • new rom? not sure what that means but I dont think so.The OS version is android 2.3.5 on galaxy and 2.3.4 on HTC – Snake Apr 30 '12 at 03:15
  • There's a problem in the S2 that I once ran into, it picks up resources from the wrong resource folder. To check out which folder the devices pick up resources from, you can try the following: use different images in different resource folders with the same name and check which device is loading which. – Vikram Bodicherla Apr 30 '12 at 03:17
  • http://www.cyanogenmod.com/devices/samsung-galaxy-s2, install on the S2, and rerun your test to see the density – L7ColWinters Apr 30 '12 at 03:17
  • I did your test Vikram and both are being picked up from the High density folder... L7, the problem is not with S2. it is with HTC amaze displaying the images smaller than expected..plus dont want to damage the S2 phone :) – Snake Apr 30 '12 at 03:35
  • with the xdpi/ydpi of 160 on the S2, I would say that it is the S2 that has the problem.. Could you post the code that you did to get these results. Also look up NANDROID, might help you in this endeavor – L7ColWinters Apr 30 '12 at 03:44
  • In the emulator it is looking as expected (which is the S2).. I added the code – Snake Apr 30 '12 at 03:58
  • i looked up the xdpi/ydpi on my incredible and its 254, pretty sure the xdpi and ydpi should be much higher on your s2 but it looks like the system doesn't use these values and that they are wrong quite a bit. I have no idea why the images would be different but I would like to see if installing a new rom would help – L7ColWinters Apr 30 '12 at 04:05
  • Where and how are you displaying the image? Can you show us the code? (both xml and java) – Erol Aug 03 '12 at 03:13
  • In the bottom portion of the screen. Its a cards game. I posted xml/java. It is supposed to be 13 image view but for simplicity I showed 3 on the xml – Snake Aug 03 '12 at 05:06
  • @L7ColWinters - why do you go on about ROMS? The images differ in size because the DPI is higher on the Amaze. The ROM has nothing to do with it. – Glenn Bech Aug 03 '12 at 12:46
  • How large are the bitmaps? (in pixels?) – Glenn Bech Aug 06 '12 at 09:55
  • Would it be possible for you to post a screenshot from the S2 so I can compare it to how it looks on my Sensation? (I purchased your game) – Glenn Bech Aug 08 '12 at 10:16
  • Hi Glen, Thank you so much for the dedication. I awarded you the bounty since it will expire soon and you have provided the most meaningful answer. If you go to google play and look at the game screenshots, this is taken from S2 and this is exactly how it looks. I fixed it now porgrammatically by taking the screen width and setting the images width accordingly. But I still can't figure out why the extreme difference is image view. please compare your sensation to the screenshots on google play and let me know what you think (if it is the same then why Note, S3 and HTC amaze behaves different) – Snake Aug 09 '12 at 04:25

4 Answers4

2

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.

Glenn Bech
  • 6,103
  • 4
  • 39
  • 56
  • We are talking here about two devices that are both "High Density". HTC has a density of 256 ppi and S2 has density of 207 ppi. I agree the images won't be exactly the same size but to have it too much smaller (around half the size) does not make sense. Could it be that S2 is reporting the X/Y values wrong? I thought they are not used though. Since both reporting DPI of 240 – Snake Aug 03 '12 at 15:43
  • EDIT:We are talking here about two devices that are both "High Density". HTC has a density of 256 ppi and S2 has density of 207 ppi. I agree the images won't be exactly the same size but to have it too much smaller (around half the size) does not make sense. Could it because S2 is reporting the X/Y values wrong it is making the image big? I thought they are not used though. Since both reporting DPI of 240. People using HTC and Note are saying the cards too small to see. On my S2 they are big. What should I do! It defeats what I learns about densities and folder – Snake Aug 03 '12 at 15:51
  • What's your game's name? ill be happy to test it on my HTC sensation – Glenn Bech Aug 06 '12 at 20:37
  • The problem is that it is not free it is called Trex – Snake Aug 06 '12 at 22:32
0

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.

Ray
  • 429
  • 6
  • 16
0

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

Rohan Prabhu
  • 7,180
  • 5
  • 37
  • 71
  • It does not say why I am having the problem or how to fix. My issue is not with the X/Y values as I don't use them. I just put them out for people to answer my question if they need them. My issue is with the image size – Snake Aug 03 '12 at 15:47
0

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. . . . :)

Community
  • 1
  • 1
Shreyash Mahajan
  • 23,386
  • 35
  • 116
  • 188
  • Both screens are considered normal size.screen so using diferent layout folder does not help – Snake Aug 06 '12 at 22:32