进度条没有显示

时间:2018-04-27 00:49:15

标签: 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">


<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

                }
            })
}

1 个答案:

答案 0 :(得分:1)

自己想出来。不知道为什么,但改变了进度条的标签

<android.support.v4.widget.ContentLoadingProgressBar

简单地

<ProgressBar

让它发挥作用

相关问题