自定义ProgressDialog实现帧动画

作者: 喂_balabala | 来源:发表于2018-01-02 10:12 被阅读0次
    //弹出加载中对话框
    myProgressDialog=new WjProgressDialog(getActivity());
    myProgressDialog.show();
    
    public class WjProgressDialog extends ProgressDialog {
    
        public WjProgressDialog(Context context) {
            super(context, R.style.CustomProgressDialog);
        }
    
        public WjProgressDialog(Context context, int theme) {
            super(context, theme);
        }
    
        @Override
        public void show() {
            super.show();
            setContentView(R.layout.customprogressdialog);
        }
    
        @Override
        public void dismiss() {
            super.dismiss();
        }
    }
    

    R.layout.customprogressdialog

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center">
        <ProgressBar
            android:id="@+id/loadingProgress"
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:background="@color/transparent"
            android:layout_gravity="center"
            style="?android:progressBarStyleInverse"
            android:indeterminateDrawable="@drawable/refresh_ainm"
            />
        <TextView
            android:id="@+id/loadingMsg"
            android:layout_marginTop="10dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="数据加载中..."
            android:layout_gravity="center"
            />
    </LinearLayout>
    

    refresh_ainm

    <?xml version="1.0" encoding="utf-8"?>
    <animation-list  xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false">
        <item android:drawable="@mipmap/loading1" android:duration="50"/>
        <item android:drawable="@mipmap/loading2" android:duration="50"/>
        <item android:drawable="@mipmap/loading3" android:duration="50"/>
        <item android:drawable="@mipmap/loading4" android:duration="50"/>
        <item android:drawable="@mipmap/loading5" android:duration="50"/>
        <item android:drawable="@mipmap/loading6" android:duration="50"/>
        <item android:drawable="@mipmap/loading7" android:duration="50"/>
        <item android:drawable="@mipmap/loading8" android:duration="50"/>
        <item android:drawable="@mipmap/loading9" android:duration="50"/>
        <item android:drawable="@mipmap/loading10" android:duration="50"/>
        <item android:drawable="@mipmap/loading11" android:duration="50"/>
        <item android:drawable="@mipmap/loading12" android:duration="50"/>
        <item android:drawable="@mipmap/loading13" android:duration="50"/>
        <item android:drawable="@mipmap/loading14" android:duration="50"/>
        <item android:drawable="@mipmap/loading15" android:duration="50"/>
        <item android:drawable="@mipmap/loading16" android:duration="50"/>
        <item android:drawable="@mipmap/loading17" android:duration="50"/>
        <item android:drawable="@mipmap/loading18" android:duration="50"/>
        <item android:drawable="@mipmap/loading19" android:duration="50"/>
        <item android:drawable="@mipmap/loading20" android:duration="50"/>
        <item android:drawable="@mipmap/loading21" android:duration="50"/>
        <item android:drawable="@mipmap/loading22" android:duration="50"/>
        <item android:drawable="@mipmap/loading23" android:duration="50"/>
        <item android:drawable="@mipmap/loading24" android:duration="50"/>
        <item android:drawable="@mipmap/loading25" android:duration="50"/>
    </animation-list>
    
    myProgressDialog.setCancelable(false);//设置进度条是否可以按退回键取消
    //        设置点击进度对话框外的区域对话框不消失
    myProgressDialog.setCanceledOnTouchOutside(false);
    

    相关文章

      网友评论

        本文标题:自定义ProgressDialog实现帧动画

        本文链接:https://www.haomeiwen.com/subject/lqlfnxtx.html