真的是见鬼了!
为什么图片不能显示啊???
val mBuilder = AlertDialog.Builder(context)
val mView = context.layoutInflater.inflate(R.layout.dialog_custom_layout, null)
mView.view.setImageURI(Uri.parse(item?.image?.url))
mBuilder.setView(mView)
Log.d("wdddd",item?.image?.url)
val mDialog = mBuilder.create()
mDialog.show()
dialog_custom_layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.github.chrisbanes.photoview.PhotoView
android:id="@+id/view"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Log
D/wdddd: https://xxx/uploads/work_order_image/image/697/1562829058360.png
Image URL 没错啊,为什么就显示不了?试了Glide
也不行!
PhotoView.setImageURI(Uri)
能直接加载HttpUrl的图片资源吗?先看看源码吧:PhotoView.setImageURI(Uri)
只是简单的重写方法,再跟入AppCompatImageView
和ImageView
源码:从源码看来,
ImageView.setImageURI(Uri)
是没有直接加载HttpUrl图片资源的能力的。正确的做法如下: