Android开发:Android加载中动画AVLoadingIndicatorView

第三方效果图:

11.gif

第三方GitHub地址

https://github.com/hanzhanbing/AVLoadingIndicatorView

实际使用:

Step 1:

bulid.gradle

dependencies {
   compile 'com.wang.avi:library:2.1.3'
}

Step 2:

dialog_loading.xml




    

Step 3:

style.xml


Step 4:

LoadingDialog.java

/**
 * 加载中Dialog
 * 
 * @author hzb
 */
public class LoadingDialog extends AlertDialog {

    private static LoadingDialog loadingDialog;
    private AVLoadingIndicatorView avi;

    public static LoadingDialog getInstance(Context context) {
        loadingDialog = new LoadingDialog(context, R.style.TransparentDialog); //设置AlertDialog背景透明
        loadingDialog.setCancelable(false);
        loadingDialog.setCanceledOnTouchOutside(false);
        return loadingDialog;
    }

    public LoadingDialog(Context context, int themeResId) {
        super(context,themeResId);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.dialog_loading);
        avi = (AVLoadingIndicatorView)this.findViewById(R.id.avi);
    }

    @Override
    public void show() {
        super.show();
        avi.show();
    }

    @Override
    public void dismiss() {
        super.dismiss();
        avi.hide();
    }
}

Step 5:

加载框显示

LoadingDialog.getInstance(this).show();

加载框隐藏

LoadingDialog.getInstance(this).dismiss();

Step 6:

效果图

Android开发:Android加载中动画AVLoadingIndicatorView_第1张图片
加载中.jpg

Demo地址:

https://github.com/hanzhanbing/LoadingDialog

你可能感兴趣的:(Android开发:Android加载中动画AVLoadingIndicatorView)