两款器件,密度相近但不同的图像大小? [英] Two devices, similar densities yet different image sizes?

查看:114
本文介绍了两款器件,密度相近但不同的图像大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

确定这里是puzzelling我,我真的想你帮我出了问题。
我测试我的应用程序既惊奇HTC和Galaxy S2(我所知都是高密度),无论是在3.7-4.3范围内屏幕

的问题是,在同一图像看上去在两个屏幕上的大小方面不同。宏达惊奇它要小得多。我有我的3与适当大小不同的文件夹绘制(这是我应该需要反正这里是因为这两个设备是相同的密度)

我做了一些DisplayMatrics调试,我发现HTC的惊奇如下:

 密度1.5
desnityDPI 240
高像素:540
宽度像素:960
xdpi 258
ydpi 256

不过,对于银河S2的显示指标是:

 密度1.5
desnityDPI 240
高像素:480
宽度像素:800
xdpi 160
ydpi 160

那么,为什么这两个设备上的图像大小不同可以有人向我解释。在HTC惊奇图像比对S2小得多?
谢谢

编辑:用于获取DP资讯code是

  DisplayMetrics MT = getApplicationContext()getResources()getDisplayMetrics()。

编辑:

 <的RelativeLayout的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:ID =@ + ID / mainLayout
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT
    机器人:背景=@绘制/地毯
    机器人:clipChildren =假
    机器人:clipToPadding =假
    机器人:keepScreenOn =真正的>
    < RelativeLayout的
        机器人:ID =@ + ID / relativeLayoutBottom
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_alignParentBottom =真
        机器人:layout_centerHorizo​​ntal =真
        机器人:clipChildren =假
        机器人:clipToPadding =假>        < ImageView的
            机器人:ID =@ + ID / ivBottom1
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT/>        < ImageView的
            机器人:ID =@ + ID / ivBottom2
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginLeft =20dp/>        < ImageView的
            机器人:ID =@ + ID / ivBottom3
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_marginLeft =40dp/>
    < / RelativeLayout的>   < / RelativeLayout的>私人无效初始化(ArrayList的< CardSuitNumber>卡){    RelativeLayout的flBottom =(RelativeLayout的)findViewById(R.id.relativeLayoutBottom);
    player1.clearAll();    的for(int i = 0; I< GameConstants.MAXRANKS;我++){
        player1.addCard((ImageView的)flBottom.getChildAt(一));
    }
}
公共无效addCard(ImageView的IM){
        可绘制可绘制= card.getCardSuitNumber()getDrawable(mActivity)。
        im.setImageDrawable(绘制);
        imsetVisibility(View.VISIBLE);
}


解决方案

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

源代码的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.

这篇关于两款器件,密度相近但不同的图像大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆