开发者

ImageView is being re-sized - why?

开发者 https://www.devze.com 2023-03-09 16:53 出处:网络
I have the following image in my app: It\'s a 59x60 PNG. I use it in the following layout: <RelativeLayout

I have the following image in my app: It's a 59x60 PNG.

ImageView is being re-sized - why?

I use it in the following layout:

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_开发者_如何转开发height="fill_parent"
    android:id="@+id/headerContainer"       
    xmlns:android="http://schemas.android.com/apk/res/android">

    <ImageView
        android:id="@+id/menu_refresh"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/menu_bt_refresh"
        android:layout_alignParentRight="true" />

</RelativeLayout>

When I run it in my Nexus One, the width of the ImageView is 89 pixels. Why?


See my answer here: Set size of ImageView in px at runtime

It is resizing it due to a different screen density than the base 160 dpi:

59x240/160 = 88.5

A workaround is to use android:layout_width="59px" and android:layout_height="60"

0

精彩评论

暂无评论...
验证码 换一张
取 消