Dialog Animation using windowAnimations
来源:互联网 发布:小爱同学 知乎 编辑:程序博客网 时间:2024/06/03 12:35
Dialog Animation using windowAnimations
In this exercise, we are going to apply slide-in and slide-out animation on dialog, using windowAnimations.
Create/modify /res/values/styles.xml to add animation style of DialogAnimation, using build-in animation of slide_in_left and slide_out_right.
Implement our dialog layout, /res/layout/dialoglayout.xml.
MainActivity.java
Main layout:
Create/modify /res/values/styles.xml to add animation style of DialogAnimation, using build-in animation of slide_in_left and slide_out_right.
<resources> <style name="AppTheme" parent="android:Theme.Light" /> <style name="DialogAnimation"> <item name="android:windowEnterAnimation">@android:anim/slide_in_left</item> <item name="android:windowExitAnimation">@android:anim/slide_out_right</item> </style></resources>
Implement our dialog layout, /res/layout/dialoglayout.xml.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_launcher"/> <Button android:id="@+id/dismiss" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="dismiss"/></LinearLayout>
MainActivity.java
package com.example.animationdialog;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import android.app.Activity;import android.app.Dialog;public class MainActivity extends Activity { Button btnOpenDialog; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); btnOpenDialog = (Button)findViewById(R.id.opendialog); btnOpenDialog.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { openDialog(); }}); } private void openDialog(){ final Dialog dialog = new Dialog(MainActivity.this); dialog.setTitle("Animation Dialog"); dialog.setContentView(R.layout.dialoglayout); dialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation; Button btnDismiss = (Button)dialog.getWindow().findViewById(R.id.dismiss); btnDismiss.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { dialog.dismiss(); }}); dialog.show(); } }
Main layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <Button android:id="@+id/opendialog" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:padding="@dimen/padding_medium" android:text="Open Dialog" tools:context=".MainActivity" /></RelativeLayout>
原文:http://android-er.blogspot.com/2012/07/dialog-animation-using-windowanimations.html
0 0
- Dialog Animation using windowAnimations
- Using the WixUI dialog library
- jquery dialog using iframe url
- android simple animation dialog from bottom
- ogre numberic value animation demo(using MFC)
- Using Keyframes – WebKit CSS Animation Examples
- Using PreTranslateMessage to handle dialog keystrokes
- Managing NuGet Packages Using the Dialog
- Using canvas to do bitmap sprite animation in JavaScript
- MIDI Driven Animation using CoreMIDI in Objective C
- Using hardware layers to improve Android animation performance
- Dialog with HTML skin using CDHtmlDialog and SetWindowRgn
- Using a modal .NET dialog to display AutoCAD object properties
- Using a modeless .NET dialog to display AutoCAD object properties
- Summary : Creating Dialog Boxes using ASP.NET, JavaScript and IE
- Using AutoCAD's file selection dialog from .NET
- Using JavaScript in PeopleSoft: Creating your own dialog boxes
- Using Dialog Templates to create an InputBox() in C++
- JS function document.onclick(){}报错Syntax error on token "function", delete this token
- storm 文档(1)----文档主页
- QTextStream和QDataStream的区别
- 公司新来了一个漂亮前台,面试一路过关斩将,结果一语惊人引发了大家的集体沉默!
- MVC——入门+最简单的小实例
- Dialog Animation using windowAnimations
- oracle体系结构解析(综合网友的)
- JNI加载Native Library 以及 跨线程和Qt通信
- GPU破解神器Hashcat使用简介
- android lcd调试 高通平台lcd调试深入分析总结(mipi和rgb接口)
- 解决ORA-01034/ORA-27101
- 【BZOJ2243】【SDOI2011】染色 树链剖分
- 第十三周项目1-数组大折腾(五)
- MVC学习笔记