解決glide有些手機長圖不顯示的問題
阿新 • • 發佈:2018-12-13
GlideApp.with(this)
.asFile()
.load(data.showImges[0])
.placeholder(R.mipmap.default_work_loading_image)
.error(R.mipmap.default_work_loading_image)
.skipMemoryCache(true)
.into(object : SimpleTarget<File>(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL) {
override fun onResourceReady(resource: File, transition: Transition<in File>?) {
showImageIV.setImage(ImageSource.uri(Uri.fromFile(resource)), ImageViewState(1.0f, PointF(0f, 0f), 0))
}
override fun onLoadFailed(errorDrawable: Drawable?) {
super.onLoadFailed(errorDrawable)
var layoutParams = showImageIV.layoutParams as LinearLayout.LayoutParams
layoutParams.height = ScreenUtils.getScreenWidth( [email protected])
layoutParams.width = ScreenUtils.getScreenWidth([email protected])
showImageIV.layoutParams = layoutParams
}
})
<com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView android:id="@+id/showImageIV" android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="gone" />
implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.5.0'