2

我想将 ImageView 放入 ListView 行中,使其适合设备屏幕的边缘。

这是我目前的布局:

<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 中:

<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。没运气。

毕加索设置:

Picasso.with(context) //
        .load(iim.getResized()) //
        .placeholder(R.drawable.placeholder) //
        .error(R.drawable.error)
        .fit().centerInside()
        .into(vh.item_image);

任何人都知道如何处理这个问题?

4

3 回答 3

4

尝试:

android:scaleType="centerCrop" 

在xml中

于 2014-01-22T08:40:23.003 回答
1

在你的程序中使用这个 .centerCrop()

Picasso.with(context) //
    .load(iim.getResized()) //
    .placeholder(R.drawable.placeholder) //
    .error(R.drawable.error)
    .centerCrop() //thissss
    .into(vh.item_image);

或在您的 xml 中:

android:scaleType="centerCrop" 
于 2019-08-19T08:59:16.520 回答
0

你的 ImageView 高度现在是 0dp。您需要设置 layout_height。你的宽度很好。

于 2014-02-05T19:21:33.193 回答