所以我正在使用这个聊天应用程序。我可以发送短信和图片。
问题是每当我发送图像或接收图像模糊时。虽然当我刷新布局(我有SwipeRefreshLayout)时,图像会变得清晰。
我有典型的Adapter类,recyclerView和图像的布局。
这仅在Glide图片库中发生,并且可以与Picasso一起正常使用。但是我只想使用Glide。这可能是什么问题?
这是我使用Glide的方式:
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {
switch (holder.getItemViewType()){
case 1:
ViewHolder1 viewHolder1 = (ViewHolder1)holder;
viewHolder1.Text.setText(messageList.get(position).getMessage());
break;
case 2:
ViewHolder2 viewHolder2 = (ViewHolder2)holder;
Glide.with(viewHolder2.Image.getContext())
.load(messageList.get(position).getMessage())
.placeholder(R.drawable.ic_image_send_24dp)
.crossFade()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(viewHolder2.Image);
break;
}
}
下面是图像布局:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp">
<RelativeLayout
android:id="@+id/message_root"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:background="@drawable/rect_round_primary_color">
<ImageView
android:id="@+id/imageView_message_image"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:paddingTop="8dp"
tools:src="@drawable/ic_image_send_24dp" />
</RelativeLayout>
</FrameLayout>
答案 0 :(得分:1)
好的,所以我找到了解决方案。在Imageview
android:layout_height="wrap_content"
中的布局文件中,应该类似于android:layout_height="250dp"
OR
滑行使用override(width, height)
。