标签:
1 这是一个简单的但是感觉还不错的加载栋 布局如下
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content"> <RelativeLayout android:layout_width="60dp" android:alpha="0.8" android:background="@drawable/ios_loading_bg" android:layout_height="60dp"> <ImageView android:id="@+id/circle" android:layout_width="25dp" android:layout_centerInParent="true" android:src="@drawable/ios_loading" android:layout_height="25dp" /> </RelativeLayout> </LinearLayout>
2 加载动画如下
<?xml version="1.0" encoding="utf-8"?> <rotate xmlns:android="http://schemas.android.com/apk/res/android" android:duration="6000" android:fromDegrees="0" android:interpolator="@android:anim/linear_interpolator" android:pivotX="50%" android:pivotY="50%" android:repeatCount="infinite" android:toDegrees="+1800" />
3 加载对话框代码如下
package com.che300.price.component; import android.app.Activity; import android.app.ProgressDialog; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.ImageView; import android.widget.TextView; import com.che300.price.R; /** * Created by Administrator on 2016/7/25. */ public class SimpleLoadingDialog { ProgressDialog pd_; Context context_; View dialog; public SimpleLoadingDialog(Context context) { pd_ = new ProgressDialog(context, R.style.DialogStyle); context_ = context; initView(); } private void initView() { dialog = LayoutInflater.from(context_).inflate(R.layout.ios_loading, null); } public void show() { if (context_ instanceof Activity) { if (((Activity) context_).isFinishing()) return; } ImageView view1 = (ImageView) dialog.findViewById(R.id.circle); Animation anim = AnimationUtils.loadAnimation(context_, R.anim.laoding_circle); view1.startAnimation(anim); pd_.show(); pd_.setContentView(dialog); } public void setCancelable(boolean cancelable) { pd_.setCancelable(cancelable); } public void dismiss() { if (context_ instanceof Activity) { if (((Activity) context_).isFinishing()) return; } pd_.dismiss(); } public void setMessage(String mess) { TextView message = (TextView) dialog.findViewById(R.id.textView1); message.setText(mess); } public boolean isShowing() { return pd_.isShowing(); } public Context getContext(){ return context_; } }
4 实现效果
标签:
原文地址:http://www.cnblogs.com/seanzhoutao/p/5703682.html