drawal/loading.xml
<?xml version="1.0" encoding="utf-8"?>
<animated-rotate android:drawable="@drawable/share_popout_icon_loading" android:pivotX="50.0%" android:pivotY="50.0%"
xmlns:android="http://schemas.android.com/apk/res/android" />
、、-------------------------------------------------------------
总觉的自带的progressdialog很丑,所以为了让自己看着舒服一些,不得以就得自己定义样式了,自定义Progressdialog其实很简单,一个layout文件,一个shape文件
再来,然后再有一个资源文件就可以了。
一下是代码
自定义Progressdialog布局文件
[html] view plaincopy
- <?xml version="1.0" encoding="utf-8"?>
- <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@drawable/bg_dialog_shape"
- android:gravity="center" >
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:gravity="center_horizontal"
- android:orientation="vertical" >
- <ProgressBar
- android:id="@+id/oahprogressbar"
- style="@android:style/Widget.ProgressBar.Small"
- android:layout_width="30dip"
- android:layout_height="30dip"
- android:indeterminateDrawable="@drawable/progress" />
- <TextView
- android:id="@+id/oaprogresstitle"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="20dip"
- android:gravity="center_vertical"
- android:text="正在验证..."
- android:textColor="@color/white" />
- </LinearLayout>
- </FrameLayout>
ProgressBar
[html] view plaincopy
- indeterminateDrawable的属性
[html] view plaincopy
- <?xml version="1.0" encoding="utf-8"?>
- <rotate xmlns:android="http://schemas.android.com/apk/res/android" >
- <rotate xmlns:android="http://schemas.android.com/apk/res/android"
- android:drawable="@drawable/loading" <!--这就是一张图片,不需要每一个状态一张图片-->
- android:pivotX="50%"
- android:pivotY="50%" />
- </rotate>
重写ProgressDialog ,
[java] view plaincopy
- package com.zl.dialog.view;
- import com.zl.payslip.R;
- import android.app.Dialog;
- import android.app.ProgressDialog;
- import android.content.Context;
- import android.os.Bundle;
- /**
- * @author gqs
- * @version 创建时间:2012-11-23 上午10:59:43
- * 类说明
- */
- public class MyDialog extends ProgressDialog{
- public PaySlipDialog(Context context, int theme) {
- super(context, theme);
- // TODO dvsdfads
- }
- public PaySlipDialog(Context context) {
- super(context);
- // TODO sdfsdf
- }
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- // TODO Auto-generated method stub
- super.onCreate(savedInstanceState);
- // progressDialog.setIndeterminate(true);
- setCancelable(false);
- //progressDialog.show()
- setContentView(R.layout.progressdialog_layout);
- }
- public void showDialog()
- {
- show();
- }
- }
最后在Acivity里面直接调用就行了
public void showDialog(Context context)
{
MyDialog dialog = new MyDialog(context);
dialog.showDialog();
}