Android 进度条未显示
我正在学习在Android中使用片段,我正在使用片段显示从URL下载的图像,这就是我需要进度条的原因。但是,一旦我执行应用程序,在显示图像之前,进度条不会显示 这是我的片段xml:Android 进度条未显示,android,android-studio,android-fragments,kotlin,Android,Android Studio,Android Fragments,Kotlin,我正在学习在Android中使用片段,我正在使用片段显示从URL下载的图像,这就是我需要进度条的原因。但是,一旦我执行应用程序,在显示图像之前,进度条不会显示 这是我的片段xml: <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <I
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/firstFragmentImageView"
android:scaleType="centerCrop"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.v4.widget.ContentLoadingProgressBar
android:id="@+id/firstFragmentProgressBar"
android:visibility="visible"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content" /></FrameLayout>
这就是我在下载图像时显示进度条的功能:
private fun loadImageUsingGlide(){
firstFragmentProgressBar.visibility = View.VISIBLE
Glide.with(this).asBitmap()
.load(Uri.parse(imageUrl))
.into(object : BitmapImageViewTarget(firstFragmentImageView){
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
super.onResourceReady(resource, transition)
firstFragmentProgressBar.visibility = View.INVISIBLE
}
})
}
我自己想出来的。不知道为什么,但将进度条的标记从
<android.support.v4.widget.ContentLoadingProgressBar
简单地
<ProgressBar
成功了