Android Studio 3.0 Beta 5
glide:3.7.0
我正在使用滑动将图像加载到CircleImageView中。但是,在滚动recyclerview之前,图像不会加载。有时滚动时不顺畅。
这是我的观看者:
public class MovieActorsViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.civActorPicture) CircleImageView actorPicture;
@BindView(R.id.tvName) TextView name;
@BindView(R.id.tvCharacter) TextView character;
private Context context;
public MovieActorsViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
context = itemView.getContext();
}
public void populateActor(Actor actor) {
Glide.with(context)
.load(MovieImage.build(actor.getProfile_path(), MovieImage.ImageSize.w92))
.placeholder(R.drawable.people_placeholder)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(actorPicture);
name.setText(actor.getName());
character.setText(actor.getCharacter());
}
}
我正在使用的布局。 TextView总是被填充。但是,当我打开细节屏幕时。我必须向前和向后滚动才能加载图像。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="6dp">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/civActorPicture"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_gravity="center"
android:scaleType="centerCrop"
tools:src="@drawable/people_placeholder"/>
<TextView
android:id="@+id/tvName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="4dp"
tools:text="Micheal Keaton"/>
<TextView
android:id="@+id/tvCharacter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="4dp"
tools:text="Adrian Toomes / The Vulture"/>
</LinearLayout>
答案 0 :(得分:1)
尝试在.asBitmap()
之前添加.load()
方法,这解决了我的问题
Glide.with(context)
.asBitmap()
.load(MovieImage.build(actor.getProfile_path(), MovieImage.ImageSize.w92))