我試圖在我的 ImageView 中使用 Glide 顯示影像無濟于事。我沒有收到任何錯誤,但我也沒有看到任何影像
build.gradle 依賴:
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
我的 ImageView 布局:
<ImageView
android:id="@ id/profilPicture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="@drawable/medicine">
</ImageView>
在我的 MainActivity 中,我嘗試在執行緒中顯示影像
val thread = Thread {
try {
Glide.with(this)
.load("http://via.placeholder.com/300.png")
.into(profilPicture)
} catch (e: Exception) {
e.printStackTrace()
}
}
thread.start()
uj5u.com熱心網友回復:
Glide 不需要執行緒。它以 ui 執行緒異步方式作業。還檢查您的影像大小和互聯網連接。
Glide.with(this).load(url).into(view);
uj5u.com熱心網友回復:
您不需要thread為加載創建單獨的內容,因為Glide它適合您。只是:
Glide.with(this)
.load("http://via.placeholder.com/300.png")
.into(profilPicture)
就夠了
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/423133.html
標籤:
上一篇:無法決議來自類的方法的符號訊息
下一篇:滑行不顯示影像
