Android实现Zaker的加载对话框
来源:互联网 发布:js json 数组 map 编辑:程序博客网 时间:2024/05/20 01:10
仔细的看了看自己的博客上一篇写的博客的时间,发现好久好久没更新自己的博客了,主要是目前自己手上的这个外包项目太赶了,实在没太多的时间来更新呀,只能心有余而力不足呀。以后还是尽量的抽更多的时间来分享自己的一些学习方法或者自己胡乱搞的新东西,呵呵。废话不多说了,先进入今天要给大家分享的是一个定制的属于自己的Dialog。
这里要实现的是一个仿Zaker的等待对话框,相信用过Zaker的人也很多也比较熟悉了。
继续博客风格,先上效果图,再分析然后放源代码
实现的效果图:
对于Dialog的一些用法大家还不熟悉的可以上网自己搜索一下,其实要实现这样的一个效果很简单,无外乎就是继承了Dialog使用上了自己的布局和自己的主题。然后中间的那个旋转的刷新按钮就是一个旋转动画。好了不分析多了,相信聪明的你一看就懂,下面给出核心的代码:
结出核心的代码:
public class MyProgressDialog extends Dialog {private Context context = null;private TextView tv_msg;public MyProgressDialog(Context context) {super(context);this.context = context;}public MyProgressDialog(Context context, boolean cancelable,OnCancelListener cancelListener) {super(context, cancelable, cancelListener);this.context = context;// TODO Auto-generated constructor stub}public MyProgressDialog(Context context, int theme) {super(context, theme);this.context = context;// 加载自己定义的布局View view = LayoutInflater.from(context).inflate(R.layout.loading, null);ImageView img_loading = (ImageView) view.findViewById(R.id.img_loading);ImageView img_close = (ImageView) view.findViewById(R.id.img_close);tv_msg = (TextView) view.findViewById(R.id.tv_msg);// 加载XML文件中定义的动画RotateAnimation rotateAnimation = (RotateAnimation) AnimationUtils.loadAnimation(context, R.anim.rotate_refresh_drawable_default);// 开始动画img_loading.setAnimation(rotateAnimation);//为Dialoge设置自己定义的布局setContentView(view);//为close的那个文件添加事件img_close.setOnClickListener(new View.OnClickListener() {public void onClick(View v) {dismiss();}});}public void setMsg(String msg) {if (null != tv_msg) {tv_msg.setText(msg);}}public void setMsg(int resId) {if (null != tv_msg) {tv_msg.setText(context.getString(resId));}}}
旋转动画的文件:
<?xml version="1.0" encoding="utf-8"?><rotate xmlns:android="http://schemas.android.com/apk/res/android" android:duration="800" android:fromDegrees="0.0" android:interpolator="@android:anim/linear_interpolator" android:pivotX="50.0%" android:pivotY="50.0%" android:repeatCount="infinite" android:toDegrees="360.0" />
在使用的Activity只要注意在使用的构造方法中要记得为其设置自己定义的主题
progressDialog = new MyProgressDialog(this, R.style.CustomProgressDialog);
样式文件:
<style name="CustomDialog" parent="@android:style/Theme.Dialog"> <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> <style name="CustomProgressDialog" parent="@style/CustomDialog"> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowNoTitle">true</item> </style>
好了,如此简单的一个功能就完成了。希望能对大家有点小小的帮助吧。
如需转载引用请注明出处:http://blog.csdn.net/jiahui524
- Android实现Zaker的加载对话框
- [转载]Android实现Zaker的加载对话框
- Android 加载对话框的实现
- android 实现加载动画对话框
- 模仿Zaker加载框
- Android性能优化之解密ZAKER,网易云阅读等新闻应用的内容缓存加载方式
- zaker splash页面实现
- 关于Zaker图片启动页面的效果实现
- Android对话框的实现
- ZAKER
- android中自定义加载的对话框。。。。
- Android自定义对话框的实现
- Android之对话框的实现
- Android-对话框dialog的实现
- 自定义对话框的实现--Android
- Android自定义加载对话框
- Android中自定义的加载对话框和加载条
- Android中自定义的加载对话框和加载条
- error while loading shared libraries: libperl.so: cannot open shared object file: No such file or di
- eryteu
- 数据仓库设计思路
- 3ds max更改项目目录
- C语言运算符优先级
- Android实现Zaker的加载对话框
- 工作安排
- Android开发者网站改版闲谈
- 在ubuntu中删除乱码文件的方法
- PrimeSense OpenNI VS. Microsoft SDK
- 最近比较忙,项目较累
- hdu 2873 Bomb Game
- How to Completely Fix privacyiconclient Error
- 28个Unix/Linux的命令行神器