自定义Dialog
来源:互联网 发布:移动数据专业认证考试 编辑:程序博客网 时间:2024/06/16 00:18
1.使用LayoutInflater.from(this).inflater(R.layout.mydialog,null)获取一个布局,存于View对象里面。2.对View里面的控件进行动画处理。3.创建Dialog对象,在对象形参里面添加两个属性,属性1:上下文,属性2:style。4.调用setContentView()方法。方法里面有两个参数,1:布局文件。2:布局参数new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,LinearLayout.LayoutParams.FILL_PARENT));
public class MyDialog { Dialog dialog; RotateAnimation rotateAnimation; public void showDialog(Context context) { View view = LayoutInflater.from(context).inflate(R.layout.mydialog,null); ImageView image = (ImageView) view.findViewById(R.id.image); AnimationSet animationSet = new AnimationSet(true); rotateAnimation = new RotateAnimation(0f,360000000f,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f); rotateAnimation.setDuration(9900000); animationSet.addAnimation(rotateAnimation); image.startAnimation(animationSet); dialog = new Dialog(context,R.style.mydialog); dialog.setCancelable(false); dialog.setContentView(view, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)); dialog.show(); } public void disMiss() { dialog.dismiss(); }}
0 0
- 自定义Dialog---继承Dialog
- 自定义Dialog android Dialog
- 自定义Dialog
- 自定义Dialog
- 自定义dialog
- 自定义 Dialog
- 自定义dialog
- 自定义 dialog
- 自定义Dialog
- 自定义 Dialog
- 自定义Dialog
- 自定义dialog
- 自定义Dialog
- 自定义 Dialog
- 自定义Dialog
- 自定义Dialog
- 自定义Dialog
- 自定义Dialog
- reimu hakurei
- AR/VR learning (3)--虚拟按键(virtualButton)的测试与使用
- Linux下打包压缩war、解压war包和jar命令
- Consul入门05 - 健康检测
- java中的域,静态域,实例域
- 自定义Dialog
- 字符驱动程序内核编程小结
- java.text.Format及相关类详解
- React-route和Webpack快速构建一个react程序
- 自定义View系列教程08--滑动冲突的产生及其处理
- 1、TCP/IP协议簇
- Linux下安装Tomcat服务器和部署Web应用
- 验证Jdk安装用记事本写的文件如何运行注意事项
- The APK file does not exist on disk.Error while Installing APK