Two devices, the same density, but different image sizes?

Well, here's the problem that puzzles me is that I really want you to help me. I am testing my application with both the amazement of HTC and the Galaxy S2 (as I know, both are high density), and both in the range of the screen are 3.7-4.3

The problem is that the same image looks different in terms of size on both screens. Surprisingly, HTC is much smaller. I have 3 downloadable folders with corresponding different sizes (which I will need here because both devices have the same density)

I did some debugging in DisplayMatrics, and I found surprise for HTC as follows:

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

However, for Galaxy S2, 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 image sizes on both devices are different. Are HTC Amazing much smaller on images than on S2? Thanks you

Edit: the code used to get the DP information,

 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); } 
0
source share
4 answers

The answer is in 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 a 4.52-inch display. HTC Amaze 4G, on the other hand, comes with a screen similar in size to the international version of the Galaxy S2-4.3 inches.

HTC Amaze has a higher resolution and a smaller physical screen. This results in a higher pixel density, which means smaller physical pixels, because more of them need to be overflowed in a denser place.

Thus, an image, for example, 240x160, will be smaller on Amaze.

The reported DPI values ​​for S2 are clearly erroneous. According to the indicated metrics, this is β€œ800/160 = 5 inches on the long side and 480/160 = 3 inches on the short side. This would give a screen size of sqrt (5 * 5 + 3 * 3) = 5.8 inches.

The DPI values ​​for Amaze are correct. As we can see, do we make simple Pythagoras. Sqrt (960/258 ^ 2 + 540/256 ^ 2) = 4.27 "

As a developer, I experience the same thing when switching from my HTC test device to the touch and to S2.

+2
source

HTC's xdpi and ydpi are very high, so the image is smaller.

I remember that there was a mistake due to which the reported xdpi and ydpi were wrong, and, to be honest, they look wrong.

0
source

I'm not sure, but the only solution I found out is based on your problem: you have to make the layout according to the screen resolution of the device.

As if,

Galaxy SII Support layout-normal-hdpi

As if,

Perhaps HTC is surprised by the support of a large-screen layout.

Therefore, try to make the layout in accordance with the device, and it will solve your problem.

Hope this helps you.

Other details that you asked your question: android-layout-issue-for-htc-evo-3d

Enjoy the coding. ,, :)

0
source

Source: https://habr.com/ru/post/922184/


All Articles