如何使用 ImageView 显示全尺寸图像? [英] How to display an image full size with ImageView?

查看:25
本文介绍了如何使用 ImageView 显示全尺寸图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试以全尺寸显示图像时遇到问题.我试图用 wrap_content 显示图像.但它是较小的真实图像.

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" />

我去这个图像的属性并查看一些信息:尺寸 211 x 74.然后我尝试显示具有固定宽度和高度的图像.我发现它更大了.

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.

推荐答案

添加一个 scaleType 到你的 ImageView

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" />

来自文档 android:scaleType="center"

图像在视图中居中,但不执行缩放.

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

这篇关于如何使用 ImageView 显示全尺寸图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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