【FastDev4Android框架开发】非常漂亮的进度指示器AVLoadingIndicatorView的使用讲解(十八)

jerry Android 2015年11月26日 收藏

().前言:   

      今天我们的项目继续更新,今天主要要加入一个非常漂亮的进度指示器AVLoadingIndicatorView(开源地址)效果很不错,用起来非常简单和平时ProgressBar一样简单。效果如下:

     FastDev4Android框架项目地址:https://github.com/jiangqqlmj/FastDev4Android 

().简要介绍:   

   AVLoadingIndicatorView是一个Android平台进度动画的集合框架,我们可以非常简单的配置和使用动画。

().使用方式

      3.1.AndroidStudio框架引入配置:build.grade配置


  1.  dependencies {
  2.        compile 'com.wang.avi:library:1.0.0'
  3.        compile'com.nineoldandroids:library:2.4.0'
  4.     }

    3.2.布局引入加载控件



  1. <?xmlversion="1.0" encoding="utf-8"?>
  2. <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
  3.    xmlns:app="http://schemas.android.com/apk/res-auto"
  4.     android:orientation="vertical"android:layout_width="match_parent"
  5.    android:layout_height="match_parent">
  6.     <LinearLayout
  7.        android:layout_width="fill_parent"
  8.         android:layout_height="49dp"
  9.         android:background="#e7abff"
  10.         android:gravity="center"
  11.         >
  12.         <TextView
  13.            android:layout_width="wrap_content"
  14.            android:layout_height="wrap_content"
  15.            android:layout_centerInParent="true"
  16.            android:textColor="@color/white"
  17.            android:text="进度动画实例"/>
  18.     </LinearLayout>
  19.     <ScrollView
  20.        android:layout_width="fill_parent"
  21.        android:layout_height="fill_parent">
  22.         <LinearLayout
  23.            android:layout_width="fill_parent"
  24.            android:layout_height="fill_parent"
  25.            android:orientation="vertical">
  26.             <!--BallPulse-->
  27.             <LinearLayout
  28.                android:layout_width="fill_parent"
  29.                android:layout_height="wrap_content"
  30.                android:orientation="horizontal">
  31.                 <TextView
  32.                    android:layout_width="wrap_content"
  33.                    android:layout_height="wrap_content"
  34.                    android:layout_centerInParent="true"
  35.                    android:textColor="@color/black"
  36.                    android:text="BallPulse:"/>
  37.                <com.wang.avi.AVLoadingIndicatorView
  38.                    android:id="@+id/avloadingIndicatorView_BallPulse"
  39.                    android:layout_width="wrap_content"
  40.                    android:layout_height="wrap_content"
  41.                    android:visibility="visible"
  42.                    app:indicator="BallPulse"
  43.                    app:indicator_color="@color/red"
  44.                     />
  45.             </LinearLayout>
  46.             <!--BallGridPulse-->
  47.             <LinearLayout
  48.                android:layout_width="fill_parent"
  49.                android:layout_height="wrap_content"
  50.                android:orientation="horizontal">
  51.                 <TextView
  52.                    android:layout_width="wrap_content"
  53.                    android:layout_height="wrap_content"
  54.                    android:layout_centerInParent="true"
  55.                    android:textColor="@color/black"
  56.                    android:text="BallGridPulse:"/>
  57.                <com.wang.avi.AVLoadingIndicatorView
  58.                    android:id="@+id/avloadingIndicatorView_BallGridPulse"
  59.                    android:layout_width="wrap_content"
  60.                    android:layout_height="wrap_content"
  61.                    android:visibility="visible"
  62.                    app:indicator="BallGridPulse"
  63.                    app:indicator_color="@color/red"
  64.                     />
  65.             </LinearLayout>
  66.  
  67.             <!--BallClipRotate-->
  68.             <LinearLayout
  69.                android:layout_width="fill_parent"
  70.                android:layout_height="wrap_content"
  71.                android:orientation="horizontal">
  72.                 <TextView
  73.                    android:layout_width="wrap_content"
  74.                    android:layout_height="wrap_content"
  75.                    android:layout_centerInParent="true"
  76.                    android:textColor="@color/black"
  77.                    android:text="BallGridPulse:"/>
  78.                <com.wang.avi.AVLoadingIndicatorView
  79.                    android:id="@+id/avloadingIndicatorView_BallClipRotate"
  80.                    android:layout_width="wrap_content"
  81.                    android:layout_height="wrap_content"
  82.                    android:visibility="visible"
  83.                    app:indicator="BallClipRotate"
  84.                    app:indicator_color="@color/red"
  85.                     />
  86.             </LinearLayout>
  87.             <!--BallClipRotatePulse-->
  88.             <LinearLayout
  89.                android:layout_width="fill_parent"
  90.                android:layout_height="wrap_content"
  91.                android:orientation="horizontal">
  92.                 <TextView
  93.                    android:layout_width="wrap_content"
  94.                    android:layout_height="wrap_content"
  95.                    android:layout_centerInParent="true"
  96.                    android:textColor="@color/black"
  97.                    android:text="BallClipRotatePulse:"/>
  98.                <com.wang.avi.AVLoadingIndicatorView
  99.                    android:id="@+id/avloadingIndicatorView_BallClipRotatePulse"
  100.                    android:layout_width="wrap_content"
  101.                    android:layout_height="wrap_content"
  102.                    android:visibility="visible"
  103.                    app:indicator="BallClipRotatePulse"
  104.                    app:indicator_color="@color/red"
  105.                     />
  106.             </LinearLayout>
  107.  
  108.             <Button
  109.                android:id="@+id/progress_start"
  110.                android:layout_width="wrap_content"
  111.                android:layout_height="wrap_content"
  112.                android:text="打开动画"/>
  113.             <Button
  114.                android:id="@+id/progress_stop"
  115.                android:layout_width="wrap_content"
  116.                android:layout_height="wrap_content"
  117.                android:text="关闭动画"/>
  118.         </LinearLayout>
  119.     </ScrollView>
  120. </LinearLayout>


      3.3.手动控制布局显示和隐藏,具体Activity代码如下:


  1. packagecom.chinaztt.fda.test;
  2. importandroid.os.Bundle;
  3. importandroid.view.View;
  4. importandroid.widget.Button;
  5. importcom.chinaztt.fda.ui.R;
  6. importcom.chinaztt.fda.ui.base.BaseActivity;
  7. importcom.wang.avi.AVLoadingIndicatorView;
  8. importorg.androidannotations.annotations.EActivity;
  9.  
  10. /**
  11.  * 当前类注释:
  12.  * 项目名:FastDev4Android
  13.  * 包名:com.chinaztt.fda.test
  14.  * 作者:江清清 on 15/11/3 08:37
  15.  * 邮箱:jiangqqlmj@163.com
  16.  * QQ: 781931404
  17.  * 公司:江苏中天科技软件技术有限公司
  18.  */
  19. @EActivity
  20. public classAVLoadingIndicatorActivity extends BaseActivity{
  21.     private Buttonprogress_start,progress_stop;
  22.     private AVLoadingIndicatorViewavloadingIndicatorView_BallPulse;
  23.     @Override
  24.     protected void onCreate(BundlesavedInstanceState) {
  25.         super.onCreate(savedInstanceState);
  26.        setContentView(R.layout.av_loading_indicator_layout);
  27.        avloadingIndicatorView_BallPulse=(AVLoadingIndicatorView)this.findViewById(R.id.avloadingIndicatorView_BallPulse);
  28.        progress_start=(Button)this.findViewById(R.id.progress_start);
  29.        progress_stop=(Button)this.findViewById(R.id.progress_stop);
  30.  
  31.         //打开动画
  32.         progress_start.setOnClickListener(newView.OnClickListener() {
  33.             @Override
  34.             public void onClick(View v) {
  35.                avloadingIndicatorView_BallPulse.setVisibility(View.VISIBLE);
  36.             }
  37.         });
  38.         //关闭动画
  39.         progress_stop.setOnClickListener(newView.OnClickListener() {
  40.             @Override
  41.             public void onClick(View v) {
  42.                avloadingIndicatorView_BallPulse.setVisibility(View.GONE);
  43.             }
  44.         });
  45.  
  46.  
  47.     }
  48. }


        3.4.实现效果如下:


().官方可选动画




上面为该库提供的所有动画的实例,下面对于每一个动画的配置信息做如下说明(以行为单位):

第一行:BallPulse,BallGridPulse,BallClipRotate,BallClipRotatePulse

第二行:SquareSpin,BallClipRotateMultiple,BallPulseRise,BallRotate

第三行:CubeTransition,BallZigZag,BallZigZagDeflect,BallTrianglePath

第四行:BallScale,LineScale,LineScaleParty,BallScaleMultiple

第五行:BallPulseSync,BallBeat,LineScalePulseOut,LineScalePulseOutRapid

第六行:BallScaleRipple,BallScaleRippleMultiple,BallSpinFadeLoader,LineSpinFadeLoader

第七行:TriangleSkewSpin,Pacman,BallGridBeat,SemiCircleSpin

 

         到此位置关于AVLoadingIndicatorView框架做出漂亮的ProgressBar,同时我们的项目已经配置该动画集框架.欢迎大家去Github站点进行clone或者下载浏览:https://github.com/jiangqqlmj/FastDev4Android 同时欢迎大家starfork整个开源快速开发框架项目~