您的位置:首页 > 其它

安卓开发动画效果

2015-05-04 21:43 183 查看
动画在很多应用中都存在,尤其是游戏类的应用,在做android开发时,UI往往是最费时间,但一个效果炫丽的UI也往往是一款应用吸引人的地方。而动画效果可以做出很多炫丽的效果,下面列举下android的动画开发——Animation的动画效果。

动画类型

Android的animation由四种类型组成

XML中 

alpha渐变透明度动画效果
scale渐变尺寸伸缩动画效果
translate画面转换位置移动动画效果
rotate画面转移旋转动画效果
JavaCode中
AlphaAnimation渐变透明度动画效果
ScaleAnimation渐变尺寸伸缩动画效果
TranslateAnimation画面转换位置移动动画效果
RotateAnimation画面转移旋转动画效果
Android动画模式

Animation主要有两种动画模式:

一种是tweened animation(渐变动画)
XML中JavaCode
alphaAlphaAnimation
scaleScaleAnimation
一种是frame by frame(画面转换动画)
XML中JavaCode
translateTranslateAnimation
rotateRotateAnimation
在XML文件中定义动画

① 打开Eclipse,新建Android工程

② 在res目录中新建anim文件夹

③ 在anim目录中新建一个myanim.xml(注意文件名小写)
④ 加入XML的动画代码

共同的布局文件

<?xml version="1.0" encoding="utf-8"?>  
<LinearLayout xmlns:Android="http://schemas.android.com/apk/res/android"  
    android:layout_width="fill_parent"  
    android:layout_height="fill_parent"  
    android:orientation="vertical" >  
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
    android:layout_width="fill_parent"  
    android:layout_height="wrap_content"  
    android:orientation="horizontal">  
  
    <Button  
        android:id="@+id/Alpha"  
        android:layout_width="wrap_content"  
        android:layout_height="wrap_content"  
        android:text="淡入淡出" />  
    <Button  
        android:id="@+id/scale"  
        android:layout_width="wrap_content"  
        android:layout_height="wrap_content"  
        android:text="缩放效果" />  
    <Button  
        android:id="@+id/rotate"  
        android:layout_width="wrap_content"  
        android:layout_height="wrap_content"  
        android:text="旋转效果" />  
    <Button  
        android:id="@+id/translate"  
        android:layout_width="wrap_content"  
        android:layout_height="wrap_content"  
        android:text="移动效果" />  
    </LinearLayout>  
    <ImageView  
        android:id="@+id/image"  
        android:layout_width="wrap_content"  
        android:layout_height="wrap_content"  
        android:src="@drawable/a" />  
      
  
</LinearLayout>  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: