我尝试在Glide中使用StateListDrawable R.drawable.image,但它总是显示错误R.drawable.default_image。但是,如果用R.drawable.image_add_sel替换R.drawable.image,它将正常显示。我能知道为什么吗?
Glide.with(context)
.load(R.drawable.image)
.error(R.drawable.default_image)
.placeholder(R.drawable.default_image)
.diskCacheStrategy(DiskCacheStrategy.RESULT)
.into(imageView);
R.drawable.image如下:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/image_add_sel" android:state_focused="true"/>
<item android:drawable="@drawable/image_add_sel" android:state_pressed="true"/>
<item android:drawable="@drawable/image_add_sel" android:state_selected="true"/>
<item android:drawable="@drawable/image_add_nor"/>
</selector>
答案 0 :(得分:0)
我只是想知道你为什么不用,
imageView.setImageResource(R.drawable.image);