自定义ProgressDialog
来源:互联网 发布:js call 编辑:程序博客网 时间:2024/06/05 17:59
在开发项目中,数据大部分都是从网络上请求的,所以要有进度动画,方便用户知道是在进行请求,所以为了自己方便使用,就自定义了dialog来当做请求动画。
很简单,直接上代码:
public MyDialog(Context context) { super(context, R.style.MyDialogStyle);}public MyDialog(Context context, int theme) { super(context, theme);}@Overrideprotected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.loading_log); setScreenBrightness(); //为了使用户点击空白就消失,设置一下dialog的属性
this.setCancelable(false);//按返回键不消失 this.setCanceledOnTouchOutside(false);//按空白处不消失 this.setOnShowListener(new OnShowListener() { @Override public void onShow(DialogInterface dialog) { ImageView image = (ImageView) MyDialog.this.findViewById(R.id.dialog_img); Animation anim = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); anim.setRepeatCount(Animation.INFINITE); // 设置INFINITE,对应值-1,代表重复次数为无穷次 anim.setDuration(1000); // 设置该动画的持续时间,毫秒单位 anim.setInterpolator(new LinearInterpolator()); // 设置一个插入器,或叫补间器,用于完成从动画的一个起始到结束中间的补间部分 image.startAnimation(anim); } });}private void setScreenBrightness() { Window window = getWindow(); WindowManager.LayoutParams lp = window.getAttributes(); /** * 此处设置亮度值。dimAmount代表黑暗数量,也就是昏暗的多少,设置为0则代表完全明亮。 * 范围是0.0到1.0 */ lp.dimAmount = 0; window.setAttributes(lp);}
0 0
- 【progressDialog】自定义progressDialog
- 自定义ProgressDialog
- 自定义ProgressDialog
- 自定义progressdialog
- 自定义progressDialog
- 自定义ProgressDialog
- 自定义progressdialog
- 自定义progressDialog
- 自定义progressDialog~~~
- 自定义ProgressDialog
- 自定义ProgressDialog
- 自定义ProgressDialog
- 自定义ProgressDialog
- 自定义ProgressDialog
- 自定义progressdialog
- 自定义ProgressDialog
- 自定义ProgressDialog
- ProgressDialog自定义方法
- JUC框架部分小结
- Quartzs的job,trriger监听器源码分析
- JSON总结
- .NoClassDefFoundError: [Lorg/hibernate/engine/FilterDefinition;
- 网络知识总结
- 自定义ProgressDialog
- snprintf函数的使用
- @media媒体查询判断ipad和iPhone各版本
- Android开发-Fragment之间传值-2-AndroidStudio
- 算法入门:双指针法
- TPS和事务响应时间的关系、计算公式
- 函数参数传递的三种方式
- 增强学习
- 下面有关Ext2和ext3文件系统的描述,错误的是?