如何使图像视图适合图像的宽度和高度

时间:2018-08-22 14:37:11

标签: android imageview

enter image description here

我是android开发的新手。我正在从数据库(Firebase)检索图像的图像中有一个图像视图。我的问题是... 图像不适合图像视图.. Dslr相机照片适合..但是 在手机相机照片上,它不适合它看起来不太好。我希望图像视图根据图像的宽度和高度进行扩展或适合图像,并且最大高度应为600dp左右

我使用了此代码

android:adjustViewBounds="true"
android:scaleType="fitCenter"

5 个答案:

答案 0 :(得分:1)

设置<!Doctype html> <body> <input type="text" id="myInput" onkeyup="SearchBar()" placeholder="type in an item" title="Type in a name"> <ul id="myUL"> <li><a href="main.html" onclick=''>apple</a></li> <li><a href="main.html" onclick=''>fruit</a></li> <li><a href="main.html" onclick=''>shirt</a></li> <li><a href="main.html" onclick=''>thing</a></li> <li><a href="main.html" onclick=''>stack</a></li> <li><a href="main.html" onclick=';'>overflow</a></li> <li><a href="main.html" onclick=''>list</a></li> </ul> </body>

android:scaleType="fitXY"

答案 1 :(得分:0)

尝试使用此参数:android:scaleType="centerInside"

答案 2 :(得分:0)

设置以下属性:

android:layout_width="600dp"
android:layout_height="600dp"
android:scaleType="fitXY"

根据需要更改尺寸
如果您使用android:scaleType="centerInside",则小于ImageView的图像将保留其大小。

答案 3 :(得分:0)

请尝试以下代码

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="600dp"
    android:scaleType="fitXY"
    android:src="@drawable/yourimage"/>

答案 4 :(得分:0)

在ImageeView的XML文件中使用它是解决android:scaleType =“ fitXY”或“ centerInside”或“ centerCrop”问题的一个属性