Android: 使用滑行在 ListView 中加载图像问题
Android: Image loading issue in ListView by using glide
我正在使用 glide 在 ListView 中加载图像(ImageView 的高度和宽度是 wrap_content)
代码
Glide.with(context).load(rowItem.getPosteduserpostimage()).error(R.drawable.bg_480_800).placeholder(R.drawable.loading_img).into(holder.ivPostedImage);
第一次加载时,我可以正确获取图像(见图像)
滚动后,当我再次观看同一张图片时,它看起来像
那么,滚动后如何显示实际图像
注意: 我的 ImageView 高度和宽度是 wrap_content
编辑
对不起,我忘了说,我在 RelativeLayout
中使用 ImageView
XML代码
<RelativeLayout
android:id="@+id/rl_lv_user_post_adapter_img_holder"
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_below="@+id/tv_user_posted_msg_post_items" >
<ImageView
android:id="@+id/iv_posted_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#ffffff"
android:contentDescription="@string/cont_desc"/>
</RelativeLayout>
@kiran 删除
android:layout_centerInParent="true"
实际上,这就是解决问题并将图像置于中心的原因。
我把 xml 代码改成了这样
<RelativeLayout
android:id="@+id/rl_lv_user_post_adapter_img_holder"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_below="@+id/tv_user_posted_msg_post_items" >
<ImageView
android:id="@+id/iv_posted_img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:scaleType="fitCenter"
android:background="#ffffff"
android:contentDescription="@string/cont_desc"/>
</RelativeLayout>
然后它工作正常
我正在使用 glide 在 ListView 中加载图像(ImageView 的高度和宽度是 wrap_content)
代码
Glide.with(context).load(rowItem.getPosteduserpostimage()).error(R.drawable.bg_480_800).placeholder(R.drawable.loading_img).into(holder.ivPostedImage);
第一次加载时,我可以正确获取图像(见图像)
滚动后,当我再次观看同一张图片时,它看起来像
那么,滚动后如何显示实际图像
注意: 我的 ImageView 高度和宽度是 wrap_content
编辑 对不起,我忘了说,我在 RelativeLayout
中使用 ImageViewXML代码
<RelativeLayout
android:id="@+id/rl_lv_user_post_adapter_img_holder"
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_below="@+id/tv_user_posted_msg_post_items" >
<ImageView
android:id="@+id/iv_posted_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#ffffff"
android:contentDescription="@string/cont_desc"/>
</RelativeLayout>
@kiran 删除
android:layout_centerInParent="true"
实际上,这就是解决问题并将图像置于中心的原因。
我把 xml 代码改成了这样
<RelativeLayout
android:id="@+id/rl_lv_user_post_adapter_img_holder"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_below="@+id/tv_user_posted_msg_post_items" >
<ImageView
android:id="@+id/iv_posted_img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:scaleType="fitCenter"
android:background="#ffffff"
android:contentDescription="@string/cont_desc"/>
</RelativeLayout>
然后它工作正常