gpt4 book ai didi

android - 如何使用 ImageView 显示全尺寸图像?

转载 作者:太空狗 更新时间:2023-10-29 15:42:05 25 4
gpt4 key购买 nike

当我尝试以全尺寸显示图像时遇到问题。我试图用 wrap_content 显示图像。但实际图像较小。

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

enter image description here

我转到此图像的属性并查看一些信息:尺寸 211 x 74。然后我尝试以固定宽度和高度显示图像。我看到它更大了。

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

ImageView with wrap_content这是正确的方法吗?我们是否必须固定尺寸才能以全尺寸显示图像?请帮我解释并解决这个问题。

最佳答案

添加一个 scaleType 到你的 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.

关于android - 如何使用 ImageView 显示全尺寸图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17564753/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com