/**第二步style文件:
* 显示正在加载动画
* @param context
*/
public static Dialog showLoadingDialog(Context context){
//创建Dialog并传递style文件
UtilLog.d("context:"+context);
final Dialog dialog = new Dialog(context, R.style.dialog);
// 设置它的ContentView
dialog.setContentView(R.layout.dialog_loading_layout);
dialog.show();//显示dialog
return dialog;
}
<style name="dialog" parent="@android:style/Theme.Dialog"> <item name="android:windowFrame">@null</item> <item name="android:windowIsFloating">true</item> <item name="android:windowIsTranslucent">true</item> <item name="android:windowNoTitle">true</item> <item name="android:background">@android:color/transparent</item> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:backgroundDimEnabled">true</item> <item name="android:backgroundDimAmount">0.6</item> </style>
第三步布局文件:
<?xml version="1.0" encoding="utf-8"?>第四步此文件放在drawable文件夹 :
<ProgressBar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/reg_req_code_gif_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminateBehavior="repeat"
android:indeterminateDrawable="@drawable/dialog_loading_anim_progress" >
</ProgressBar>
<?xml version="1.0" encoding="utf-8"?>
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@mipmap/dialog_loading_icon"
android:fromDegrees="0.0"
android:pivotX="50.0%"
android:pivotY="50.0%"
android:toDegrees="-360.0" />