android 开发 制作弹出等待进度条

技术点:

dialog;ProgressBar;animated-rotate;

弹出框:

import com.carspeak.client.R;

import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.view.Gravity;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * 等待进度条
 * @author huqiang
 *
 */
public class WaitProgressDialog extends Dialog {
    private Context context = null;
    private static WaitProgressDialog wProgressDialog = null;

    public WaitProgressDialog(Context context){
        super(context);
        this.context = context;
    }

    public WaitProgressDialog(Context context, int theme) {
        super(context, theme);
    }

    public static WaitProgressDialog createDialog(Context context){
        wProgressDialog = new WaitProgressDialog(context,R.style.WaitProgressDialog);
        wProgressDialog.setContentView(R.layout.waitprogressdialog);
        wProgressDialog.getWindow().getAttributes().gravity = Gravity.CENTER;

        return wProgressDialog;
    }
}

R.style.WaitProgressDialog:

<style name="WaitProgressDialog" parent="@style/TipsDialog">
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:backgroundDimEnabled">false</item>
    </style>

R.layout.waitprogressdialog:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="horizontal">
    <ProgressBar
        android:id="@+id/pb_process"
           android:layout_width="40dp"
           android:layout_height="40dp"
           android:layout_gravity="center"
           style="?android:attr/progressBarStyle" 
           android:indeterminate="false"
           android:indeterminateDrawable="@anim/process_round"/>
</LinearLayout>

@anim/process_round:

<?xml version="1.0" encoding="utf-8"?>
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"  
    android:drawable="@drawable/ic_loading"  
    android:pivotX="50%"  
    android:pivotY="50%" />

 

转载于:https://www.cnblogs.com/feijian/p/4503168.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值