码迷,mamicode.com
首页 > 移动开发 > 详细

Android 自定义progressDialog

时间:2015-04-25 16:50:16      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:

1.
导入CustomProgressDialog.java


2.
styles.xml:

 <style name="CustomProgressDialog" parent="@android :style/Theme.Dialog">
        <item name="android:windowBackground">@android :color/transparent</item>
        <item name="android:windowNoTitle">true</item>
  <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>

3.
\layout中定义自己的布局:

<?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">
    <ImageView
        android:id="@+id/loadingImageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@anim/progress_round"/>
    <TextView
        android:id="@+id/id_loadingmsg"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:textSize="20dp"/>
</LinearLayout>

4.
实现转动的效果,循环显示图片:
anim中progress_round.xml

<?xml version="1.0" encoding="utf-8"?>
<animation-list
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:oneshot="false">
    <item android:drawable="@drawable/progress_1" android:duration="200"/>
    <item android:drawable="@drawable/progress_2" android:duration="200"/>
    <item android:drawable="@drawable/progress_3" android:duration="200"/>
    <item android:drawable="@drawable/progress_4" android:duration="200"/>
    <item android:drawable="@drawable/progress_5" android:duration="200"/>
    <item android:drawable="@drawable/progress_6" android:duration="200"/>
    <item android:drawable="@drawable/progress_7" android:duration="200"/>
    <item android:drawable="@drawable/progress_8" android:duration="200"/>
</animation-list>

5.
使用

import com.youthforty.xxxxxx.CustomProgressDialog;

......

private CustomProgressDialog pDialog=null;

......

if (pDialog == null){
 pDialog = CustomProgressDialog.createDialog(Login.this);
 pDialog.setMessage("正在加载中...");
}            
pDialog.show();

......


pDialog.dismiss();

Android 自定义progressDialog

标签:

原文地址:http://my.oschina.net/u/1046838/blog/406280

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!