ContentLoadingProgressBar在隐藏之前未显示最短时间

问题描述 投票:0回答:3

我正在尝试使用ContentLoadingProgressBar在隐藏自身之前显示1秒。但是我似乎找不到如何在recyclerview中正确使用它的任何示例。

因此,我已经尝试过仅对其进行测试,但无法在最短的时间内显示它。我该怎么办?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.core.widget.ContentLoadingProgressBar
        android:id="@+id/main_progressbar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        style="?android:attr/progressBarStyleLarge"
        android:visibility="visible"/>

</RelativeLayout>

我只是尝试这样做:

mProgressBar.show();
mProgressBar.hide();

但是隐藏前1秒钟没有显示。它只是自动隐藏。

android android-progressbar
3个回答
0
投票
mProgressBar.show();
Handler().postDelayed({
  mProgressBar.hide();
}, 1000)

0
投票

ContentLoadingProgressBar的最小阈值时间为500ms,因此您应该等待该时间再隐藏


0
投票

ContentLoadinProgressBar的构建是为了防止在对progressBar进行频繁的show hide调用期间UI闪烁。因此,如果您在调用hide();之后快速调用show();,则它将忽略show();。这是正常的。以防止闪烁。

© www.soinside.com 2019 - 2024. All rights reserved.