原文链接:https://blog.csdn.net/zhaozhiwen6140/article/details/51849835
在网络请求拿取数据的过程中,如果出现网速太慢以及数据量太大的情况,一般加入一个要求用户先进行等待的界面,等到数据全部拿到再进行展示效果会好一些,展示如下。
1.首先在drawable文件夹下新建一个animated-rotate标签的xml文件,如下:
<?xml version="1.0" encoding="utf-8"?> <animated-rotate xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/ic_custom_loading" android:pivotX="50%" android:pivotY="50%" android:fromDegrees="0" android:toDegrees="360"/>
ic_custom_loading是要展示的图片
2.在main.xml文件中实现对Progressbar的布局,如下:
<LinearLayout运行,出现图片中的效果,图片会一直旋转,完成。
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal">
<ProgressBar
android:id="@+id/progressbar"
android:layout_width="28dp"
android:layout_height="28dp"
android:indeterminateDrawable="@drawable/load_animate" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/string_loadings"
android:textSize="18sp"/>
</LinearLayout>