安卓Loading各种动画样式

这里写图片描述

1. 集成依赖

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

2.将控件添加到自己的布局

<com.wang.avi.AVLoadingIndicatorView
        android:layout_width="wrap_content"  
        android:layout_height="wrap_content"
        app:indicatorName="BallPulseIndicator"
        />

控件样式:

/**
"BallPulseIndicator",
"BallGridPulseIndicator",
"BallClipRotateIndicator",
"BallClipRotatePulseIndicator",
"SquareSpinIndicator",
"BallClipRotateMultipleIndicator",
"BallPulseRiseIndicator",
"BallRotateIndicator",
"CubeTransitionIndicator",
"BallZigZagIndicator",
"BallZigZagDeflectIndicator",
"BallTrianglePathIndicator",
"BallScaleIndicator",
"LineScaleIndicator",
"LineScalePartyIndicator",
"BallScaleMultipleIndicator",
"BallPulseSyncIndicator",
"BallBeatIndicator",
"LineScalePulseOutIndicator",
"LineScalePulseOutRapidIndicator",
"BallScaleRippleIndicator",
"BallScaleRippleMultipleIndicator",
"BallSpinFadeLoaderIndicator",
"LineSpinFadeLoaderIndicator",
"TriangleSkewSpinIndicator",
"PacmanIndicator",
"BallGridBeatIndicator",
"SemiCircleSpinIndicator",
"com.wang.avi.sample.MyCustomIndicator"
*/
view.setIndicator("BallRotateIndicator");//可以设置多种样式
view.setIndicatorColor(Color.RED);//设置颜色

文章最后附上自己的一个LoadingUtil封装:

public class LoadingUtil {
    private static Dialog dialog;
    public static void Loading_show(Context context) {
        if(dialog==null){
            AVLoadingIndicatorView view = new AVLoadingIndicatorView(context);
            view.setIndicator("BallRotateIndicator");
            view.setIndicatorColor(Color.RED);
            LinearLayout ll = new LinearLayout(context);
            ll.setOrientation(LinearLayout.VERTICAL);
            ll.setGravity(Gravity.CENTER);
            ll.addView(view,new LinearLayout.LayoutParams(200,200));
            TextView tv = new TextView(context);
            tv.setTextColor(Color.WHITE);
            tv.setTextSize(TypedValue.COMPLEX_UNIT_SP,20);
            tv.setText("加载中,请稍后...");
            ll.addView(tv,new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT));
            dialog = new Dialog(context, R.style.lode_dialog);
            dialog.setContentView(ll);// 设置布局
        }
        dialog.show();
    }

    public static void Loading_close() {
        if(dialog!=null)dialog.cancel();
    }
}

github地址:https://github.com/81813780/AVLoadingIndicatorView

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值