Animate a custom Dialog,自定义Dialog动画
Inside res/style.xml <style name="AppTheme" parent="android:Theme.Light" />
<style name="PauseDialog" parent="@android:style/Theme.Dialog">
<item name="android:windowAnimationStyle">@style/PauseDialogAnimation</item>
</style> <style name="PauseDialogAnimation">
<item name="android:windowEnterAnimation">@anim/fadein</item>
<item name="android:windowExitAnimation">@anim/fadeout</item>
</style>
Inside anim/fadein.xml <alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="500" />
Inside anim/fadeut.xml <alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/anticipate_interpolator"
android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="500" />
MainActivity
Dialog imageDiaglog= new Dialog(MainActivity.this,R.style.PauseDialog);
http://stackoverflow.com/questions/4817014/animate-a-custom-dialog
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="PauseDialog" parent="@android:style/Theme.Dialog">
<item name="android:windowAnimationStyle">@style/PauseDialogAnimation</item>
</style> <style name="PauseDialogAnimation">
<item name="android:windowEnterAnimation">@anim/spin_in</item>
<item name="android:windowExitAnimation">@android:anim/slide_out_right</item>
</style>
</resources>
The windowEnterAnimation is one of my animations and is located in res\anim. The windowExitAnimation is one of the animations that is part of the Android SDK. Then when I create the Dialog in my activities onCreateDialog(int id) method I do the following. Dialog dialog = new Dialog(this, R.style.PauseDialog); // Setting the title and layout for the dialog
dialog.setTitle(R.string.pause_menu_label);
dialog.setContentView(R.layout.pause_menu);
Alternatively you could set the animations the following way instead of using the Dialog constructor that takes a theme. Dialog dialog = new Dialog(this);
dialog.getWindow().getAttributes().windowAnimations = R.style.PauseDialogAnimation;
Animate a custom Dialog,自定义Dialog动画的更多相关文章
- 通用的Dialog自定义dialog
图样:
- 【转】bootbox自定义dialog、confirm、alert样式,以及基本设置方法setDefaults中可用参数
<html> <head> <meta charset="utf-8"> <meta name="viewport" ...
- Android自定义Dialog(美化界面)
前言:在做项目的时候,发现dialog界面太丑陋,从csdn上下载了一份自定义dialog的源码,在他的基础上对界面进行美化...有需要的朋友可以直接拿走 效果图如下: 主要代码: /** * 自定义 ...
- 自定义Dialog宽度占满屏幕
一.自定义Dialog继承Dialog public class MyDialog extends Dialog { 二.为Dialog设置样式 在style中建立新样式继承 @android:sty ...
- Android中制作自定义dialog对话框的实例
http://www.jb51.net/article/83319.htm 这篇文章主要介绍了Android中制作自定义dialog对话框的实例分享,安卓自带的Dialog显然不够用,因而我们要继 ...
- Android提高篇之自定义dialog实现processDialog“正在加载”效果、使用Animation实现图片旋转
知识点: 1.使用imageview.textview自定义dialog 2.使用Animation实现图片旋转动画效果 3.通过自定义theme去掉dialog的title 没有使用progres ...
- Android创建自定义dialog方法详解-样式去掉阴影效果
在自定义组件时,从已有组件源码中会很大收获.就拿progressDialog来说 间接父类是dialog,想了解dialog继承结构可以去百度,或者 从构造器来说ProgressDial ...
- 非自定义和自定义Dialog的介绍!!!
一.非自定义Dialog的几种形式介绍 转自:http://www.kwstu.com/ArticleView/kwstu_20139682354515 前言 对话框对于应用也是必不可少的一个组件,在 ...
- 自定义Dialog,从下面弹出
Window window= getWindow(); 只要 打开一个Activity 就有一个窗口存放这个Activity ,手机又很多个窗口,不只是一个窗口 import android.app. ...
随机推荐
- screen常用命令
1. 背景 由于经常使用ssh登录实验室的服务器训练神经网络, 而一些复杂的神经网络模型需要长时间训练,在此期间,如果出现网络等原因出现链接中断的话,服务器的进程也会被杀死,之前的一切半途而废.利用s ...
- CentOS 6.4 yum安装chrome
CentOS 6.4安装chrome浏览器 vim /etc/yum.repos.d/CentOS-Base.repo 根据你的系统增加一个节点 32-bit [google] name=Google ...
- java开发常用到的jar包总结
commons-io.jar: FileUtils 读取文件所有行 File file = new File("c:\\123.txt"); List<String> ...
- 源码编译安装git
debian上的git版本才2.1有点低了,为了安装最新版的2.11,我决定从源码编译安装一下. 预备工作: 1.安装编译工具.apt install -y build-essential 2.安装 ...
- Unity和安卓互调
Unity调安卓 AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); And ...
- Virtex6 PCIe 超简版基础概念学习(二)
Virtex6 PCIe 超简版基础概念学习(二) 分类:FPGAPCIe (2081) (0) 举报 收藏 文档版本 开发工具 测试平台 工程名字 日期 作者 备注 V1.0 ise14.7 ...
- 每日英语:Dishing the Dirt on Hand-Washing Guidelines
Americans aren't washing their hands nearly as often and as thoroughly as they should, according to ...
- Nginx 常见问题解决
如果提示端口已经被占用: probably another instance of uWSGI is running on the same address (:8002). bind(): Addr ...
- Android基础总结(二)布局,存储
常见布局 相对布局 RelativeLayout 组件默认左对齐.顶部对齐 设置组件在指定组件的右边 android:layout_toRightOf="@id/tv1" 设置在指 ...
- CSS3实现0.5px的边框
前端页面细节处理好了才会显得精致.边框在网页中是常见的一种样式了.虽然不把它处理为0.5px看上去没毛病,但是想让你做的东西征服更多的人,这些细节处理是必须的. 今天主要说一下如何让边框显示0.5px ...