Android-使ImageView适合ListView [英] Android - Fit ImageView to ListView
本文介绍了Android-使ImageView适合ListView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将ImageView放在ListView行中,以使其适合设备屏幕的边缘.
I want to fit ImageView inside a ListView row so that it fits to the edge of device's screen.
这是我当前的布局:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:smoothScrollbar="true"
android:id="@android:id/list" />
</RelativeLayout>
在custom_row.xml中:
In the custom_row.xml:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/img_item"
android:adjustViewBounds="true"/>
</RelativeLayout>
我正在使用Picasso库加载图像.我尝试使用Picasso的加载程序选项使用.centerCrop,.centerInside和.fit.没有运气.
I'm using Picasso library to load the image. I've tried using .centerCrop, .centerInside and .fit using Picasso's loader option. No luck.
毕加索设置:
Picasso.with(context) //
.load(iim.getResized()) //
.placeholder(R.drawable.placeholder) //
.error(R.drawable.error)
.fit().centerInside()
.into(vh.item_image);
有人知道如何处理这个问题吗?
Anyone knows how to deal with this problem?
推荐答案
尝试使用:
android:scaleType="centerCrop"
在xml
这篇关于Android-使ImageView适合ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文