实现类似于Playstore和Facebook的非阻塞进度对话框

4
我正在我的应用中实现自定义progressDialog,在其中我使用animation-list来显示移动图像,但是我想要的是将我的progressDialog嵌入到我的活动中,这样它就不会重叠在屏幕上,在任务完成时,视图被更新,而在返回点击活动时,活动结束。
1个回答

0
在您的活动中创建ProgressDialog并隐藏其他布局。
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/content"
        android:visibility="gone"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TextView style="?android:textAppearanceMedium"
            android:lineSpacingMultiplier="1.2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/lorem_ipsum"
            android:padding="16dp" />

    </ScrollView>

    <ProgressBar android:id="@+id/loading_spinner"
        style="?android:progressBarStyleLarge"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center" />

</FrameLayout>

从网络调用中获取数据后,隐藏ProgressBar并显示您的数据。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接