animation 之xml控制
来源:互联网 发布:淘宝售后怎么赚钱 编辑:程序博客网 时间:2024/05/22 13:24
Q群: 241359063 更精彩,欢迎共同走向创业学习之旅。
原创:kylin_zeng http://blog.chinaunix.net/uid/23795897.html在此感谢mars 老师的帮助。转载请注明原创出处,尊重他人的劳动成果。
二、第二种使用:
1、在res文件夹厦门新建一个anim的文件夹;
2、创建xml文件,并首先要加入set标签,如下:
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">
</set>
3、在该标签当中加入rotate,alpha,scale或者translate标签。
4、在代码中使用AnimationUtils当中转载xml 文件,并生产Animation对象。
例如:
1、在res下面建立一个anim文件夹。
2、里面创建了四个xml文件,alpha.xml,
rotate.xml,
scale.xml,
translate.xml
4、调用:
02_09.zip
原创:kylin_zeng http://blog.chinaunix.net/uid/23795897.html在此感谢mars 老师的帮助。转载请注明原创出处,尊重他人的劳动成果。
二、第二种使用:
1、在res文件夹厦门新建一个anim的文件夹;
2、创建xml文件,并首先要加入set标签,如下:
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">
</set>
3、在该标签当中加入rotate,alpha,scale或者translate标签。
4、在代码中使用AnimationUtils当中转载xml 文件,并生产Animation对象。
例如:
1、在res下面建立一个anim文件夹。
2、里面创建了四个xml文件,alpha.xml,
点击(此处)折叠或打开
- <?xml version="1.0" encoding="utf-8"?>
- <set xmlns:android="http://schemas.android.com/apk/res/android"
- android:interpolator="@android:anim/accelerate_interpolator">
-
- <alpha
- android:fromAlpha="1.0"
- android:toAlpha="0.0"
- android:startOffset="500"
- android:duration="500" />
- </set>
点击(此处)折叠或打开
- <?xml version="1.0" encoding="utf-8"?>
- <set xmlns:android="http://schemas.android.com/apk/res/android"
- android:interpolator="@android:anim/accelerate_interpolator">
- <rotate android:fromDegrees="0"
- android:toDegrees="360"
- android:pivotX="50%"
- //这里有三种表示方法:50 :是绝对坐标,表示屏幕上真正的50,对应代码控制中的toplant,
- // 50% : 是相对坐标,表示相对自身控件的50%,即控件的中心点。
- // 50%p: 是相对于父控件,表示父控件的50%位置。
- android:pivotY="50%"
- android:duration="5000" />
- </set>
scale.xml,
点击(此处)折叠或打开
- <?xml version="1.0" encoding="utf-8"?>
- <set xmlns:android="http://schemas.android.com/apk/res/android"
- android:interpolator="@android:anim/accelerate_interpolator">
- <scale android:fromXScale="1.0"
- android:toXScale="0.0"
- android:fromYScale="1.0"
- android:toYScale="0.0"
- android:pivotX="50%"
- android:pivotY="50%"
- android:duration="2000" />
- </set>
translate.xml
点击(此处)折叠或打开
- <?xml version="1.0" encoding="utf-8"?>
- <set xmlns:android="http://schemas.android.com/apk/res/android"
- android:interpolator="@android:anim/accelerate_interpolator">
- <translate
- android:fromXDelta="50%"
- android:toXDelta="100%"
- android:fromYDelta="0%"
- android:toYDelta="100%"
- android:duration="2000" />
- </set>
4、调用:
点击(此处)折叠或打开
- package mars.animations02;
- import android.app.Activity;
- import android.os.Bundle;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.view.animation.AlphaAnimation;
- import android.view.animation.Animation;
- import android.view.animation.AnimationSet;
- import android.view.animation.AnimationUtils;
- import android.view.animation.RotateAnimation;
- import android.view.animation.ScaleAnimation;
- import android.view.animation.TranslateAnimation;
- import android.widget.Button;
- import android.widget.ImageView;
- public class MainActivity extends Activity {
- /** Called when the activity is first created. */
- private ImageView imageView = null;
- private Button rotateButton = null;
- private Button scaleButton = null;
- private Button alphaButton = null;
- private Button translateButton = null;
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- imageView = (ImageView) findViewById(R.id.imageViewId);
- rotateButton = (Button) findViewById(R.id.rotateButtonId);
- rotateButton.setOnClickListener(new RotateButtonListener());
- scaleButton = (Button) findViewById(R.id.scaleButtonId);
- scaleButton.setOnClickListener(new ScaleButtonListener());
- alphaButton = (Button) findViewById(R.id.alphaButtonId);
- alphaButton.setOnClickListener(new AlphaButtonListener());
- translateButton = (Button) findViewById(R.id.translateButtonId);
- translateButton.setOnClickListener(new TranslateButtonListener());
- }
- private class RotateButtonListener implements OnClickListener {
- @Override
- public void onClick(View view) {
- Animation animation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.rotate);
- imageView.startAnimation(animation);
- }
- }
- private class ScaleButtonListener implements OnClickListener {
- @Override
- public void onClick(View view) {
- Animation animation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.sacle);
- imageView.startAnimation(animation);
- }
- }
- private class AlphaButtonListener implements OnClickListener {
- @Override
- public void onClick(View view) {
- //使用AnimationUtils装载动画设置文件
- Animation animation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.alpha);
- imageView.startAnimation(animation);
- }
- }
- private class TranslateButtonListener implements OnClickListener {
- @Override
- public void onClick(View view) {
- Animation animation = (Animation) AnimationUtils.loadAnimation(MainActivity.this, R.anim.translate);
- imageView.startAnimation(animation);
- }
- }
- }
02_09.zip
0
上一篇:Ubuntu文件系统层 系统启动过程详解
下一篇:animation 之动画时间的控制
相关热门文章
- Android之开发环境搭建
- Android自定义View的实现...
- AndroidManifest.xml配置文件...
- Android源码调试方法详解...
- 不用vs和cygwin!Eclipse+cdt...
- 请问Linux默认shell的是什么 ...
- 谁能够帮我解决LINUX 2.6 10...
- 现在的博客积分不会更新了吗?...
- shell怎么读取网页内容...
- ssh等待连接的超时问题...
给主人留下些什么吧!~~
评论热议
0 0
- animation 之xml控制
- animation之二,使用xml控制animat…
- animation 控件之代码控制
- animation 之动画时间的控制
- Android XML file之animation-list
- Animation之View Animation
- Animation之Property Animation
- Animation之View Animation
- 安卓开发小知识-Animation之XML文件编写
- cocos2d animation 时间控制
- JS控制animation事件
- android animation xml配置
- android animation xml
- xml写Animation动画
- Android Animation之frame animation
- 动画Animation 和 xml 解析Animation
- Animation效果控制(一)
- u3d 控制animation播放速度
- linux文件系统启动流程
- C/C++面试、笔试题
- animation 控件之代码控制
- Ubuntu文件系统层 系统启动过程详解
- 系统需求与功能需求有什么区别
- animation 之xml控制
- 1st_uC/OS-II Basic Programmers’Guide
- animation 之动画时间的控制
- animations 动画图片的播放
- 跟我一起学extjs5(06--使用图标字体来美化按钮)
- animations 之 对控件设置动画效果
- [LeetCode] Anagram
- 视图用法详解
- ramdisk.img
原创粉丝点击
热门IT博客
热门问题
老师的惩罚
人脸识别
我在镇武司摸鱼那些年
重生之率土为王
我在大康的咸鱼生活
盘龙之生命进化
天生仙种
凡人之先天五行
春回大明朝
姑娘不必设防,我是瞎子
病人血含氧量低怎么办
头皮油脂分泌过多怎么办
克林霉素副作用怎么办
喷雾喷头坏了怎么办
感冒打了预防针怎么办
西瓜苗激素中毒怎么办
吃了螃蟹内脏怎么办
w7电脑显示静音怎么办
打印机色带干了怎么办
衣服有汗臭味怎么办
衣服上有异味怎么办
棉衣上有味道怎么办
吃完饭衣服有味怎么办
热水器内胆坏了怎么办
亚克力灯罩坏了怎么办
冰柜内壁破了怎么办
超市里面有老鼠怎么办
我家超市有老鼠怎么办
德州超市有老鼠怎么办
减肥进入平台期怎么办
奶粉冲不溶于水怎么办
冬季酒变浑浊怎么办
防氧化剂吃了怎么办
呼吸了王水气体怎么办
人体被辐射后怎么办
煎刀鱼没有料酒怎么办
孕妇吃了金枪鱼怎么办
龙鱼眼睛有白膜怎么办
孕妇吃了山楂怎么办
小狗吃了芒果怎么办
狗狗吃了苹果核怎么办
蛙眼守宫寄生虫怎么办
烤茄没有锡纸怎么办
烤烤箱没有锡纸怎么办
烤东西没有锡纸怎么办
腌制的柠檬发霉怎么办
自制柠檬蜂蜜苦怎么办
柠檬蜂蜜苦了怎么办
腌制柠檬蜂蜜苦怎么办
孕妇严重便秘怎么办啊
误食水垢清洗剂怎么办