zoukankan      html  css  js  c++  java
  • android 仿zarker加载提示

    先看下效果图

    MyProgressDialog类 加载提示

    public class MyProgressDialog extends Dialog {
      public Context context;// 上下文
    
        public MyProgressDialog(Context context) {
            super(context);
            this.context = context;
        }
    
        public MyProgressDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
            super(context, cancelable, cancelListener);
            this.context = context;
        }
    
        public MyProgressDialog(Context context, int theme) {
            super(context, theme);
            this.context = context;
            View view = LayoutInflater.from(context).inflate(R.layout.load, null); // 加载自己定义的布局
            ImageView img_loading = (ImageView) view.findViewById(R.id.img_load);
            RelativeLayout img_close = (RelativeLayout) view.findViewById(R.id.img_cancel);
            RotateAnimation rotateAnimation = (RotateAnimation) AnimationUtils.loadAnimation(context, R.anim.refresh); // 加载XML文件中定义的动画
            img_loading.setAnimation(rotateAnimation);// 开始动画
            setContentView(view);// 为Dialoge设置自己定义的布局
            // 为close的那个文件添加事件
            img_close.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    dismiss();
                }
            });
        }
    }
    

     布局文件

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/loadbackgroup"
        android:gravity="center_vertical|center_horizontal"
        android:orientation="horizontal" >
    
        <TextView
            android:id="@+id/tv_msg"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dip"
            android:padding="15dip"
            android:text="正在加载 ..."
            android:textColor="#ffffff" />
    
        <ImageView
            android:id="@+id/img_load"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="10dip"
            android:background="@drawable/loadrefresh"
            android:contentDescription="@string/app_name" />
    
        <ImageView
            android:id="@+id/img_ling"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:background="@drawable/loadline"
            android:contentDescription="@string/app_name" />
    
        <RelativeLayout
            android:id="@+id/img_cancel"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:padding="15dip" >
    
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:background="@drawable/loadcancel"
                android:contentDescription="@string/app_name" />
        </RelativeLayout>
    
    </LinearLayout>
    

     需要用到的图片

    1. loadbackgroup.9.png  

    2.loadrefresh.png

    3.loadcancel.png

    4.loadline.png

    styles.xml中加入:

        <style name="CustomDialog" parent="@android:style/Theme.Dialog">
            <item name="android:windowFrame">@null</item>
            <item name="android:windowIsFloating">true</item>
            <item name="android:windowContentOverlay">@null</item>
            <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
            <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
        </style>
    
        <style name="CustomProgressDialog" parent="@style/CustomDialog">
            <item name="android:windowBackground">@android:color/transparent</item>
            <item name="android:windowNoTitle">true</item>
        </style>
    

    需要打开加载提示地方加入以下代码:

    final MyProgressDialog progressDialog = new MyProgressDialog(MainActivity.this,R.style.CustomProgressDialog);
    progressDialog.show();//显示加载提示
    

     需要关闭加载提示的地方加入:

    progressDialog.dismiss(); //关闭加载提示框
    
  • 相关阅读:
    HTML5数据推送SSE原理及应用开发
    用Docker构建分布式Redis集群
    开发者必备的12个JavaScript库
    分享:我用一天时间开发的 新年送祝福 微信手机网站(可在线体验附图)(要代码的留下邮箱)
    祝福csdn回望2014,展望2015 大致可以这样总结和展望
    对 云寻觅贴吧(http://tieba.yunxunmi.com/)的简要分析
    开源前夕先给大家欣赏一下我用C语言开发的云贴吧 网站自动兼容-移动、手机、PC自动兼容云贴吧
    舞蹈模特欣欣(六)棚拍私房 大家看看像小龙女(李若彤)吗?
    终于解决了贴吧手机版的一个重大BUG
    比基尼美女_人像摄影吧主题
  • 原文地址:https://www.cnblogs.com/flowers-yang/p/3414284.html
Copyright © 2011-2022 走看看