动画效果,针对图片实现

现在学习四种基本的简单动画效果

一、Tween Animation共同属性

  1、Duration:动画持续时间(毫秒单位)
  2、fillAfter:设置为true,动画转化在动画结束后被应用
  3、fillBefore:设置为true,动画转化在动画开始前被应用
  4、interpolator:动画插入器(加速,减速插入器)
  5、repeatCount:动画重复次数
  6、repateMode:顺序重复/倒序重复
  7、startOffset:动画之间的时间间隔

二、Animation实现方式

  1、配置文件(/res/anim)--alpha,scale,translate,rotatae
  2、JAVA代码实现--AlphaAnimation,ScaleAnimation,TranslateAnimation,RotateAnimation

三、四种基本动画

 1、AlphaAnimation(透明度动画)
  (1)fromAlpha:动画起始时的透明度
  (2)toAlpha:动画终止时的透明度
  0.0表示完全透明 1.0表示完全不透明

 2、ScaleAnimation(缩放动画)
  (1)fromX,toX分别是起始和结束时x坐标上的伸缩尺寸
  (2)fromY,toY分别是起始和结束时y坐标上的伸缩尺寸
  (3)pivotX,pivotY分别为伸缩动画相对于x,y,坐标开始的位置

 3、TranslateAnimation(位移动画)
  (1)、fromXDelta,fromYDelta分别是起始时X,Y的坐标
  (2)、toXDelta,toYDelta分别是结束时X,Y的坐标

 4、RotateAnimation(旋转动画)
  (1)、fromDegrees 起始的角度
  (2)、toDegrees 终止的角度
  (3)、pivoteX,pivoteY分别为旋转动画相对于x,y的坐标的开始位置

四、示例

配置文件实现方法

 package other;

 import com.example.allcode.ImageTest;
import com.example.allcode.R; import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView; public class Donghua extends Activity implements OnClickListener{
private Button toumingdu;
private Button suofang;
private Button weiyi;
private Button xuanzhuan; private ImageView donghua_image;
private Animation loadAnimation;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.donghua); toumingdu = (Button) findViewById(R.id.donghua_touming);
suofang = (Button) findViewById(R.id.donghua_suofang);
weiyi= (Button) findViewById(R.id.donghua_weiyi);
xuanzhuan= (Button) findViewById(R.id.donghua_xuanzhuan); donghua_image = (ImageView) findViewById(R.id.donghua_image);
toumingdu.setOnClickListener(this);
donghua_image.setOnClickListener(this);
suofang.setOnClickListener(this);
weiyi.setOnClickListener(this);
xuanzhuan.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.donghua_touming: //透明动画
loadAnimation = AnimationUtils.loadAnimation(this, R.anim.alpha);
donghua_image.startAnimation(loadAnimation);
break;
case R.id.donghua_suofang: //缩放动画
loadAnimation = AnimationUtils.loadAnimation(this, R.anim.scale);
donghua_image.startAnimation(loadAnimation);
break;
case R.id.donghua_weiyi: //位移动画
loadAnimation = AnimationUtils.loadAnimation(this, R.anim.translate);
donghua_image.startAnimation(loadAnimation);
break;
case R.id.donghua_xuanzhuan: //旋转动画
loadAnimation = AnimationUtils.loadAnimation(this, R.anim.rotate);
donghua_image.startAnimation(loadAnimation);
break;
default:
break;
}
} }

布局文件:

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <Button
android:id="@+id/donghua_touming"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="AlphaAnimation(透明度动画)" /> <Button
android:id="@+id/donghua_suofang"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ScaleAnimation(缩放动画)" /> <Button
android:id="@+id/donghua_weiyi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TranslateAnimation(位移动画)" /> <Button
android:id="@+id/donghua_xuanzhuan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RotateAnimation(旋转动画)" /> <ImageView
android:id="@+id/donghua_image"
android:layout_width="82dp"
android:layout_height="wrap_content"
android:layout_weight="0.16"
android:src="@drawable/icon_72" /> </LinearLayout>

配置文件:

目录。res-anim 自己新建

 <?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" > <alpha
android:duration=""
android:fromAlpha="0.1"//初始透明度10%
android:toAlpha="1.0" //结束透明度100%
>
</alpha> </set>

alpha.xml透明动画

 <?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" > <scale
android:duration=""
android:fillAfter="false"
android:fromXScale="0.0"
android:fromYScale="0.0"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="1.0"
android:toYScale="1.0" /> </set>

scale.xml缩放动画

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

translate.xml位移动画

 <?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" > <rotate
android:duration=""
android:fromDegrees=""
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="+360" /> </set>

rotate.xml旋转动画

效果图:

安卓开发_浅谈Android动画(一)的更多相关文章

  1. 安卓开发_浅谈Android动画(四)

    Property动画 概念:属性动画,即通过改变对象属性的动画. 特点:属性动画真正改变了一个UI控件,包括其事件触发焦点的位置 一.重要的动画类及属性值: 1.  ValueAnimator 基本属 ...

  2. 安卓开发_浅谈Android动画(三)

    一.LayoutAnimation布局动画 用于为一个layout里面的控件,或者是一个ViewGroup里面的控件设置动画效果 在res-anim文件下新建一个动画xml文件 <?xml ve ...

  3. 安卓开发_浅谈Android动画(二)

    在学习了四个基本动画之后,现在要学习一些更有用的效果 先给出所有的动画xml <?xml version="1.0" encoding="utf-8"?& ...

  4. 安卓开发_浅谈ListView(SimpleAdapter数组适配器)

    安卓开发_浅谈ListView(ArrayAdapter数组适配器) 学习使用ListView组件和SimapleAdapter适配器实现一个带图标的ListView列表 总共3部分 一.MainAc ...

  5. 安卓开发_浅谈ListView(自定义适配器)

    ListView作为一个实际开发中使用率非常高的视图,一般的系统自带的适配器都无法满足开发中的需求,这时候就需要开发人员来自定义适配器使得ListView能够有一个不错的显示效果 有这样一个Demo ...

  6. 安卓开发_浅谈Fragment之ListFragment

    ListFragment,即Fragment的一个子类,当我们用的一个Fragment只需要一个listview视图的时候使用 该类有几个特点: 1.ListFragment 本身具只有一个ListV ...

  7. 安卓开发_浅谈OptionsMenus(选项菜单)

    Android平台下所提供的菜单大体上可分为三类:选项菜单.上下文菜单和子菜单. 当Activity在前台运行时,如果用户按下手机上的Menu键,此时就会在屏幕低端弹出相应的选项菜单.但这个功能需要开 ...

  8. 安卓开发_浅谈Notification(通知栏)

    Notification通知栏是显示在手机状态的消息,代表一种全局效果的通知 快速创建一个Notification的步骤简单可以分为以下四步: 第一步:通过getSystemService()方法得到 ...

  9. 安卓开发_浅谈ListView之分页列表

    前言: 在开发的过程中,有时候我们需要从网络解析一些数据,比如最近的一些新闻,我们需要把这些数据用ListView显示出来. 因为是解析一个网络数据源,这样将会一下子将所有的数据解析出来,当数据源数据 ...

随机推荐

  1. WINDOWS 2008Server 配置nginx 反向代理服务器

    本案例有用过可行 0.先要在域名官网上面配置域名对应的IP地址,然后要在自己路由器上面将80端口映射到要装nginx服务器的IP地址. 1.从官网上面下载nginx1.6.2   WINDOWS版本的 ...

  2. CentOS 6.4 快速安装Nginx笔记

    CentOS 6.4 快速安装Nginx笔记 本系列文章由ex_net(张建波)编写,转载请注明出处. http://blog.csdn.net/ex_net/article/details/9860 ...

  3. java模仿qq好友面板的布局(BoxLayout问题)

    .............. JLabel ll = new JLabel(dlg.getNameText() + ":" + dlg.getIPText(), ii[index] ...

  4. ubuntu14.04 编译安装gcc-5.3.0

    最近编译个源码,要求对C++14的支持了,就GCC的编译安装最新的5.3.0,整个过程以root用户进行. 1.下载GCC源码,属于事后文档整理,已经不知道从哪下载了. 2.解压:tar -zxvf ...

  5. LeetCode-304. Range Sum Query 2D - Immutable

    Description: Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by ...

  6. Hekaton的神话与误解

    最近这段时间,我花了很多时间来更好的理解Hekaton——SQL Sever 2014里的全新内存表技术.我看了很多文章,了解了Haktaon的各种内部数据存储结构(主要是哈希索引和Bw-tree). ...

  7. 【分享】iOS功能界面漂亮的弹出框

    STPopup 为 iPhone 和 iPad提供了 STPopupController UINavigationController 弹出的风格. 特性: Extend your view cont ...

  8. DOM中 property 和 attribute 详解

    被问到 property 和 attribute 的区别,想来也是要好好看一下. 一.基本概念区别 其实Attribute和Property这两个单词,翻译出来都是“属性”,<js高级程序设计& ...

  9. C#设计模式——策略模式(Strategy Pattern)

    一.概述我们来实现一个企业的工资系统,该企业中不同级别的员工工资算法都不相同,针对该问题,最容易想到的莫过于在代码中堆积一大堆if…else…语句或者是switch…case…语句.如果该企业中不同级 ...

  10. Winform开发框架之权限管理系统功能介绍

    权限管理系统的重要特性总结: 1) 高度集成的权限系统.独立模块,能快速整合使用.2) 符合权限的国际通用标准,基于RBAC(基于角色的访问控制)的角色权限控制.3) 多数据库架构支持,内置支持Sql ...