How to display an image full size with ImageView?

邮差的信 提交于 2019-11-28 09:54:07

问题


I have problem when I try to display the image with full size. I tried to display image with wrap_content. But it is smaller real image.

<ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/screen1_logo" />

I go to the properties of this image and see some information: dimentions 211 x 74. Then I try to display image with fixed width and height. I see it's bigger.

<ImageView
        android:layout_width="211px"
        android:layout_height="74px"
        android:src="@drawable/screen1_logo" />

is it right way? do we must to fix size to display image with full size? Please help me to explain and resolve this problem.

回答1:


add a scaleType to your ImageView

 <ImageView
     android:scaleType="center"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/screen1_logo" />

from the doc android:scaleType="center"

Center the image in the view, but perform no scaling.




回答2:


Try adding a scaleType attribute to your view:

android:scaleType=""

The available options can be found here:

http://developer.android.com/reference/android/widget/ImageView.ScaleType.html




回答3:


Please Define scale type as fitXY

 <ImageView
            android:id="@+id/yourImageViewId"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="fitXY" />



回答4:


You are probably looking for scaleType

http://developer.android.com/reference/android/widget/ImageView.ScaleType.html




回答5:


Try adding in xml file (ImageView properties) android:adjustViewBounds="true".

<ImageView
    android:id="@+id/photoViewer"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"


来源:https://stackoverflow.com/questions/17564753/how-to-display-an-image-full-size-with-imageview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!