一:显示隐藏动画

在res目录下创建一个anim目录,然后在里面创建一个alpha.xml文件

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
>
<alpha
android:fromAlpha="1.0"
android:toAlpha="0"
android:duration="5000"
>
</alpha>
</set>

在显示的页面添加一张图片,然后在MainActivity.java文件,获得需要进行动画的对象,获得动画东西那个,将需要的对象添加动画的对象到动画的方法

package cn.szy.com;

import android.app.Activity;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView; public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main); Animation animation = AnimationUtils.loadAnimation(this, R.anim.alpha);
animation.setFillAfter(true);
ImageView imageview = (ImageView) this.findViewById(R.id.imageView1);
imageview.startAnimation(animation);
}
}

二:移动动画

在res目录下创建一个anim目录,然后在里面创建一个translate.xml文件,然后在动画里面获取了之后加载进去就行了

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
>
<translate
android:fromXDelta="0"
android:fromYDelta="0"
android:toXDelta="100"
android:toYDelta="100"
android:duration="5000"
>
</translate>
</set>

三:旋转动画

在res目录下创建一个anim目录,然后在里面创建一个rotate.xml文件,然后在动画里面获取了之后加载进去就行了

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
>
<rotate
android:fromDegrees="0" android:toDegrees="180"
android:pivotX="50%"
android:pivotY="50%"
android:duration="5000"
>
</rotate>
</set>

四:放大动画

在res目录下创建一个anim目录,然后在里面创建一个scale.xml文件,然后在动画里面获取了之后加载进去就行了

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >
<scale
android:fromXScale="1.0"
android:fromYScale="1.0"
android:toXScale="5.0"
android:toYScale="5.0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="5000"
/>
</set>

五:集合动画,将多个动画的动作写到一个文件中,会按顺序和时间进行调用,就能够实现一些复杂的动画

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
>
<translate
android:fromXDelta="0"
android:fromYDelta="0"
android:toXDelta="100"
android:toYDelta="100"
android:duration="5000"
>
</translate>
<scale
android:fromXScale="1.0"
android:fromYScale="1.0"
android:toXScale="5.0"
android:toYScale="5.0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="5000"
/>
<alpha
android:fromAlpha="1.0"
android:toAlpha="0"
android:duration="5000"
/>
</set>

Java-Android 之动画的实现的更多相关文章

  1. 79.Android之动画基础

    转载:http://a.codekk.com/detail/Android/lightSky/%E5%85%AC%E5%85%B1%E6%8A%80%E6%9C%AF%E7%82%B9%E4%B9%8 ...

  2. Android滑动动画ViewFlipper和视频播放VideoView的使用

    Android滑动动画,可以用ViewPager或者ViewFlipper实现. ViewPager自带触摸滑动功能,结合Fragment使用很好,来自补充组件android-support-v4.j ...

  3. Android的动画

    一.动画类型 Android的animation由四种类型组成:alpha.scale.translate.rotate XML配置文件中 alpha 渐变透明度动画效果 scale 渐变尺寸伸缩动画 ...

  4. Android View动画

    Animation TypeEvaluator View的animate方法 ValueAnimator ObjectAnimator AnimatorSet 使用xml来创建动画 animation ...

  5. Android Animation动画(很详细)

    Android Animation   Contents: Animations Tween Animations AnimationSet Interpolator Frame-By-Frame A ...

  6. Android Animations动画使用详解

    一.动画类型 Android的animation由四种类型组成:alpha.scale.translate.rotate XML配置文件中 alpha 渐变透明度动画效果 scale 渐变尺寸伸缩动画 ...

  7. Android 开机动画源码分析

    Android系统在启动SystemServer进程时,通过两个阶段来启动系统所有服务,在第一阶段启动本地服务,如SurfaceFlinger,SensorService等,在第二阶段则启动一系列的J ...

  8. Java&Android反编工具打包

    Java&Android反编工具: 1.Eclipse反编插件:安装到Eclipse后,可以简要的查看jar包中的*.class; 2.DoAPK:反编*.apk为smali和一些资源文件,可 ...

  9. android Animation动画的xml使用

    在Android应用程序,使用动画效果,能带给用户更好的感觉,做动画能够通过XML或Android代码来实现. Animation动画效果的实现能够通过两种方式进行实现,一种是tweened anim ...

  10. android 属性动画

    一直再追郭霖的博客和imooc上的一些新的视频,最近有讲到属性动画. 以下内容为博客学习以及imooc上视频资料的学习笔记: 在3.0之前比较常见的动画为tween动画和frame动画: tween动 ...

随机推荐

  1. bzoj1237

    假如不存在相等的两个数不能配对,那很容易贪心得到,A中rank 1匹配B中rank 1 A中rank2 匹配B中rank 2…… 有了相等不能匹配这个条件,那么A中rank i可能和rank i,i- ...

  2. SQL中and与or优先级比较

    刚刚在项目中遇到这样一个问题,SQL语句如下: select * from LOAN_BACK_LIBRARY where LIBRARY_ID=1 or LIB_ID=1 and STATUS=3 ...

  3. (转载)Chrome 快捷键 整理版

    (转载)http://www.douban.com/group/topic/13802153/ chrome窗口和标签页快捷键: Ctrl+N 打开新窗口 Ctrl+T 打开新标签页 Ctrl+Shi ...

  4. Bzoj 2346: [Baltic 2011]Lamp dijkstra,堆

    2346: [Baltic 2011]Lamp Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 428  Solved: 179[Submit][Sta ...

  5. GCC基本知识

    掌握下面的对GCC会有一个比较清晰的大致的了解: 不经意间,GCC已发展到了4.3的版本,尽管在软件开发社区之外乏人闻问,但因为GCC在几乎所有开源软件和自由软件中都会用到,因此它的编译性能的涨落会直 ...

  6. [LeetCode] Minimum Size Subarray Sum 解题思路

    Given an array of n positive integers and a positive integer s, find the minimal length of a subarra ...

  7. .net 码农转战 iOS - 初探

    好久没写博客了,之前还打算把毕业设计中涉及到的两个算法拿出来说说(脸型分析 + 声音分析),博文都写了一半了,后来实在太忙了,那篇随笔也就沉在草稿列表中没动过. 我原先是专职 .net 开发的,在公司 ...

  8. puppet任务计划

  9. hdoj 1564 Play a game

    Play a game Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  10. xutils Error:(37, 39) 错误: 无法访问HttpRequestBase 找不到org.apache.http.client.methods.HttpRequestBase的类文件

    Android 6.0(api 23)SDK已经强制移除httpclient 解决方案: 1降低api 2build.gradle中添加一句话 android { useLibrary'org.apa ...