• 自己定义progressdialog载入动画,这里还有旋转的载入条,美团,多个图片动画


    自己定义progressdialog载入动画,这里还有旋转的载入条,美团,多个图片动画

    下载Demo:http://download.csdn.net/detail/menglele1314/8775497


    public class MainActivity extends Activity {
    
        private Button submit;
    
        private AnimationDrawable fightnimation, fightnimationab;
        private ImageView pb, net, netab;
        private Dialog mLoading;
        private Animation animation;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            requestWindowFeature(Window.FEATURE_NO_TITLE);
            setContentView(R.layout.activity_main);
    
            submit = (Button) findViewById(R.id.btn_login_submit);
            
            pb = (ImageView) findViewById(R.id.iv_failure);
            animation = AnimationUtils.loadAnimation(MainActivity.this,
                    R.anim.cirle);
            animation.setInterpolator(new LinearInterpolator());
    
            netab = (ImageView) findViewById(R.id.iv_netab);
            netab.setBackgroundResource(R.anim.fight);
            fightnimationab = (AnimationDrawable) netab.getBackground();
    
            net = (ImageView) findViewById(R.id.iv_net);
            net.setBackgroundResource(R.anim.loading);
            fightnimation = (AnimationDrawable) net.getBackground();
    
            submit.setOnClickListener(new OnClickListener() {
    
                @Override
                public void onClick(View arg0) {
                    mLoading = createLoadingDialog(MainActivity.this);
                    mLoading.show();
    //                mLoading.dismiss();
    
                    pb.startAnimation(animation);
                    fightnimationab.start();
                    fightnimation.start();
    
                }
            });
        }
    
        /**
         * 得到自己定义的progressDialog
         *
         * @param context
         * @return
         */
        public static Dialog createLoadingDialog(Context context) {
            LayoutInflater inflater = LayoutInflater.from(context);
            View v = inflater.inflate(R.layout.layout_loading_dialog, null); // 得到载入view
            LinearLayout layout = (LinearLayout) v.findViewById(R.id.dialog_view); // 载入布局
            ImageView spaceshipImage = (ImageView) v.findViewById(R.id.img);
            Animation animation = AnimationUtils.loadAnimation(
                    context, R.anim.cirle); // 载入动画
            animation.setInterpolator(new LinearInterpolator());
            spaceshipImage.startAnimation(animation); // 使用ImageView显示动画
            Dialog loadingDialog = new Dialog(context, R.style.loading_dialog); // 创建自己定义样式dialog
    
            // loadingDialog.setCancelable(false);// 不能够用"返回键"取消
            loadingDialog.setContentView(layout, new LinearLayout.LayoutParams(
                    LinearLayout.LayoutParams.WRAP_CONTENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT));
            return loadingDialog;
        }
    }


    下载Demo:点击打开链接

  • 相关阅读:
    redis集群报错:(error) MOVED 5798 127.0.0.1:7001
    20190829小记
    20181114小结记录
    遇到的面试题记录
    机器学习-KNN算法原理 && Spark实现
    机器学习-KMeans算法原理 && Spark实现
    大数据开发-生产中遇到的10个致命问题
    大数据开发-Spark-闭包的理解
    大数据开发-Spark-共享变量之累加器和广播变量
    大数据开发-Spark-RDD的持久化和缓存
  • 原文地址:https://www.cnblogs.com/gcczhongduan/p/5135718.html
Copyright © 2020-2023  润新知