How to display an image full size with ImageView?(如何使用 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 显示全尺寸图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 ImageView 显示全尺寸图像?
基础教程推荐
- 如何从 logcat 中删除旧数据? 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
