1

我不知道为什么会这样:使用 Ion 库加载图像后,我的图像在图像下方和上方显示两个白条。我不想拥有那个。

图片 2014-10-03 嗯 15 42 25

我的 ImageView 显示在列表视图项中。我的适配器代码如下所示:

if (node.getImageUrl() != null) {
    ivImage.setVisibility(View.VISIBLE);
    Ion.with(ivImage)
            .placeholder(R.drawable.anne_eli_icons_set_up_anne_eli_logo_530px)
            //.error(R.drawable.error_image)
            //.animateLoad(android.R.anim.cycle_interpolator)
            .animateIn(android.R.anim.fade_in)
            .load("http://app.anne-eli.at/" + node.getImageUrl().getUrlBig());


} 别的 {
    ivImage.setVisibility(View.GONE);
}

我的图像视图布局是这样的: <LinearLayout ... <ImageView android:id="@+id/fragment_appointment_list_item_article_iv_image" android:layout_width="match_parent" android:layout_height="wrap_content" android:src="@drawable/anne_eli_icons_set_up_anne_eli_logo_530px" android:background="@color/gray1" /> </LinearLayout>

有任何想法吗?

4

2 回答 2

1

将您的 imageview 布局更改为此:

<LinearLayout ...
<ImageView
        android:id="@+id/fragment_appointment_list_item_article_iv_image"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scaleType="fitXY" <!-- this line added , also your can use other value too like cropCenter ... -->
        android:src="@drawable/anne_eli_icons_set_up_anne_eli_logo_530px"
        android:background="@color/gray1" />
</LinearLayout>
于 2014-10-03T23:54:34.573 回答
0

我认为它可能是“gray1”的任何值,但它看起来很白,因为它比背景中的图像更亮。删除 xml 中的背景属性,它将不可见。

同样,如果不在 上设置 scaleType ImageView,它将默认为center。这将尝试调整图像大小,使其适合中心ImageView而不进行裁剪。ImageView绑定到它的容器的宽度。提供的图像比这宽得多,因此它会缩小图像以适应。这意味着顶部和底部也将缩小,并且图像变得小于容器的高度。如果您希望图像靠近顶部,可以尝试将 scaleType 设置为fitStart

于 2014-10-03T23:18:56.373 回答