自定义实现ProgressDialog样式的Dialog
1. 建立一个my_progress_dialog.xml布局文件
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="200dip" android:layout_height="200dip" >
<ImageView
android:id="@+id/iv_progressDialog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/my_progress_dialog_rotate" />
<TextView
android:id="@+id/tv_progressDialog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/iv_progressDialog"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dip"
android:gravity="center"
android:text="load..." />
</RelativeLayout>
2.在res目录下建立文件anim/my_progress_dialog_rotate_anim.xml,自定义动画
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator="false" >
<!-- 定义一个MyProgressDialog中imageView转动的动画 -->
<rotate android:duration="1500"
android:fromDegrees="0"
android:interpolator="@android:anim/linear_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="-1"
android:repeatMode="restart"
android:startOffset="-1"
android:toDegrees="+360" />
</set>
3.在values的styles.xml中添加Dialog样式
<!-- 自定义loading dialog -->
<style name="myProgressDialog" parent="android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@android:color/white</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
4.自定义一个方法实现Dialog
/** * 得到自定义的progressDialog
* * @param context
* @param msg
* @return
*/
public static Dialog createLoadingDialog(Context context, String msg) {
LayoutInflater inflater = LayoutInflater.from(context);
View v = inflater.inflate(R.layout.my_progress_dialog, null);// 得到加载view
ImageView spaceshipImage = (ImageView) v.findViewById(R.id.iv_progressDialog);
TextView tipTextView = (TextView) v.findViewById(R.id.tv_progressDialog);// 提示文字
// 加载动画
Animation hyperspaceJumpAnimation = AnimationUtils.loadAnimation(context, R.anim.my_progress_dialog_rotate_anim); // 使用ImageView显示动画 spaceshipImage.startAnimation(hyperspaceJumpAnimation);
tipTextView.setText(msg);// 设置加载信息
Dialog loadingDialog = new Dialog(context, R.style.myProgressDialog);// 创建自定义样式dialog
loadingDialog.setCancelable(false);
loadingDialog .setContentView(v, new LinearLayout.LayoutParams(150, 150));
return loadingDialog;
}
转载于:https://www.cnblogs.com/arnoid/archive/2013/04/25/3042776.html
自定义实现ProgressDialog样式的Dialog相关推荐
- Android自定义类似ProgressDialog效果的Dialog
2019独角兽企业重金招聘Python工程师标准>>> Android自定义类似ProgressDialog效果的Dialog. 方法如下: 1.首先准备两张自己要定义成哪样子的效果 ...
- android progressdialog 样式,android之修改系统自带ProgressDialog样式
1.ProgressDialog默认样式是当前Activity的theme所定义的ProgressDialog样式. 继承自父类AlertDialog的style. AlertDialog的源码 st ...
- Android自定义底部带有动画的Dialog
Android自定义底部带有动画的Dialog 效果图 先看效果图,是不是你想要的呢 自定义Dialog package --.view;import android.app.Dialog; impo ...
- Android自定义底部弹出窗-dialog(2种实现分析+源码)
Android自定义底部弹出窗-dialog(2种实现分析+源码) 上线项目功能抽取,在项目开发中,我们会在许多地方会用到底部自定义弹窗,比如设置:个人账户退出,切换,照片的拍照或者相册的调出,或者一 ...
- 转:iFire:玩聚 SRBacks 自定义脚本及样式表
感谢iFire的第一时间修改并试用,而且调试出如此清新的样式. 下面转贴一下他的自定义脚本和样式表: 玩聚 SRBacks 自定义脚本及样式表 admin @ 2009-01-11 02:34 59 ...
- iOS开发UI篇 -- UISearchBar 属性、方法详解及应用(自定义搜索框样式)
很多APP都会涉及到搜索框,苹果也为我们提供了默认的搜索框UISearchBar.但实际项目中我们通常需要更改系统默认搜索框的样式.为了实现这一目标,我们需要先搞懂 UISearchBar 的属性及方 ...
- jQuery Validate 表单验证插件----自定义校验结果样式
一.下载依赖包 网盘下载:https://yunpan.cn/cryvgGGAQ3DSW 访问密码 f224 二.引入依赖包 <script src="../../scripts/j ...
- android自定义progressbar样式,Android开发中如何实现自定义ProgressBar的样式
Android开发中如何实现自定义ProgressBar的样式 发布时间:2020-11-20 16:08:10 来源:亿速云 阅读:294 作者:Leah Android开发中如何实现自定义Prog ...
- android 自定义checkBox的样式
今天,随便讲讲自定义CheckBox的样式. 第一种方法: 1.在drawable文件新建checkbox_style.xml. <?xml version="1.0" en ...
最新文章
- Netty源码分析第6章(解码器)----第4节: 分隔符解码器
- boost::units::information相关的测试程序
- C++Odd Even Sort奇偶排序的实现算法(附完整源码)
- python 学习DAY03
- 搜索引擎优化系统知名乐云seo_seo技术出名 乐云seo:如何进行搜索引擎优化?
- 升级ssl后ssh登录失效_centos7升级openssl、openssh常见问题及解决方法
- HTML5笔记:跨域通讯、多线程、本地存储和多图片上传技术
- android 获取软件签名工具,获取Android应用签名的几种方式
- ansys计算机热仿真,ANSYS仿真软件热分析
- WAP技术与网站建立(转)
- 虚拟机更新升级,原来的GuestAdditions versions版本不匹配
- HTML常见问题整理1
- 猿人学之js混淆源码乱码
- 外卖O2O的用户画像实践
- C语言写三阶矩阵的转置
- 内容策展的4个成功案例
- java配置多环境_[原创]多版本Java环境变量的配置
- bootmgr添加引导linux,总结一下bootmgr的引导模式(引导dos,nt5,nt6,grub4dos等)
- 漫谈测试员系列:无BUG不生活
- Riak学习(2):java连接Riak服务,使用Protocol Buffers连接