Android 自定义旋转进度框(单帧)
来源:互联网 发布:matlab数组写入excel 编辑:程序博客网 时间:2024/06/14 10:20
1.对话框布局文件
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" ><ImageView android:id="@+id/loadingDialog_bg" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/loding_dialog"/></LinearLayout>
2.工具类创建对话框
public class LoadingDialog{public static Dialog createLoadingDialog(Context context){LayoutInflater mInflater = LayoutInflater.from(context);LinearLayout layout = (LinearLayout) mInflater.inflate(R.layout.loading_dialog, null);ImageView image = (ImageView) layout.findViewById(R.id.loadingDialog_bg);//创建动画Animation animation = new RotateAnimation(0, 359, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);LinearInterpolator interpolator = new LinearInterpolator(); //匀速旋转animation.setInterpolator(interpolator);animation.setDuration(2000); //一次动画耗时2000msanimation.setRepeatCount(-1); //重复播放动画//显示动画image.startAnimation(animation);//创建对话框Dialog loadingDialog = new Dialog(context,R.style.dialog);loadingDialog.setContentView(layout);return loadingDialog;}}
说明:创建旋转动画时,将动画结束时的角度设置为359度,以防止动画停顿现象
3.对话框样式
<style name="dialog" parent="@android:style/Theme.Dialog"> <item name="android:windowFrame">@null</item><!--边框--> <item name="android:windowIsFloating">true</item><!--是否浮现在activity之上--> <item name="android:windowIsTranslucent">false</item><!--半透明--> <item name="android:windowNoTitle">true</item><!--无标题--> <item name="android:windowBackground">@color/transparent</item><!--背景透明--> <item name="android:backgroundDimEnabled">false</item><!--模糊--></style>
4.使用对话框
此时当需要使用对话框时,只需通过工具类实例化一个对话框即可:
Dialog dialog = LoadingDialog.createLoadingDialog(LCCXActivity.this);dialog.show();
- Android 自定义旋转进度框(单帧)
- Android自定义进度框
- Android 自定义加载进度框
- Android自定义View之进度条(带进度提示框)
- Android自定义Dialog显示进度框
- Android自定义ProgressDialog进度等待框
- Android自定义ProgressDialog进度等待框
- 自定义控件旋转圆加载进度
- Android 自定义进度图形
- android自定义加载旋转框
- Android单帧动画Rotate旋转
- Android单帧动画Rotate旋转
- Android ProgressBar ImageLoading 旋转进度值
- android progressBar 自定义 进度颜色
- android--进度框(ProgressBar)
- Android 自定义 斜线进度框 ,雨点式背景
- android:自定义Material Design风格ProgressDialog的进度框
- Android自定义View二(加载进度动画)
- 用例图
- ASP.NET如何让后台代码控制div层显示及隐藏
- 状态图与活动图
- 使用PathGradientBrush类
- wince文件存储及文件管理器(二)
- Android 自定义旋转进度框(单帧)
- 绘制文字,。说明:该文字由图片充填,图片自己找
- Wiki OI 1044 拦截导弹
- 构串操作符#和合并操作符##的用法
- .编写一个Windows应用程序,由给定数据25,15,10,30,20饼图
- hdu1251统计难题(字典树小试牛刀)
- Linux开启mysql远程连接的设置步骤
- 8086 寻址方式(一)CPU和主存中的寻址方式
- Fileatream表示文件流,它能够打开和关闭文件,并对文件进行单字节的读写操作。 StreamReader和StreamWriter以文本方式对流进行读写操作。建立一个文本文件,分别使用上面两种方