`
huakewoniu
  • 浏览: 46514 次
  • 性别: Icon_minigender_1
  • 来自: 西安
社区版块
存档分类
最新评论

scale animation

阅读更多

Scale animation: You use this type of animation to make a view smaller
or larger either on the x axis or on the y axis. You can also specify the
pivot point around which you want the animation to take place.

下面我们将要实现一个scale Animation的小列子


1)在anim文件夹下用xml定义一个scale Animation

<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">
<scale
android:fromXScale="1"
android:toXScale="1"
android:fromYScale="0.1"
android:toYScale="1.0"
android:duration="500"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="100" />
</set>

2)define the main.xml    其中listView 中的每一个item将会按照scale Animation中
定义好的方式展示出来
 
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical" android:layout_width="fill_parent"
 android:layout_height="fill_parent">
 <ListView android:id="@+id/list_view_id"
  android:persistentDrawingCache="animation|scrolling"
  android:layout_width="fill_parent" android:layout_height="fill_parent"
  android:layoutAnimation="@anim/list_layout_controller" />
 />
</LinearLayout>

注意到这里有一个android:layoutAnimation 属性
the ListView requires another XML file that acts as a mediator between itself and the animation set.
the mediator 就是上面的list_layout_controller, 用xml文件中实现, 下面是实现的代码

<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:delay="30%"
android:animationOrder="reverse"
android:animation="@anim/scale" />

这样一来就可以将listview中的item按照定义好的scale Animation展示
出来了

这是Activity的代码
package hust.ophoneclub.ScaleAnimation;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class ScaleAnimation extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        setupLiatView();
    }

 /**
  *
  */
 private void setupLiatView() {
  String[] listItems = new String[]{
    "Item1", "Item2", "Item3",
    "Item4", "Item5", "Item6"
  };
  ArrayAdapter listItemAdapter =
   new ArrayAdapter(this, android.R.layout.simple_list_item_1,
     listItems);
  ListView listView = (ListView)findViewById(R.id.list_view_id);
  listView.setAdapter(listItemAdapter);
 }
}

效果是每个item中的文字会沿着y轴扩展开来

分享到:
评论

相关推荐

    超漂亮的 Animation Scale 动画设置效果.zip

    超漂亮的 Animation Scale 动画设置效果。.zip,快速设置平铺以快速设置动画持续时间比例。

    Android代码-漂亮的二选一按钮效果。

    Simple custom ViewGroup with two shapes inside and simple scale animation View Download For project API 21 . Gradle compile 'com.steelkiwi:separate-shapes-view:1.1.0' Usage First of all, need add ...

    Animation动画详解 - v1.0

    • 1、《Animation 动画详解(一)——alpha、scale、translate、rotate、set的xml属性及用法》 • 2、《Animation动画详解(二)——Interpolator插值器》 • 3、《Animation动画详解(三)—— 代码生成alpha、...

    Animation 动画详解——alpha、scale、translate、rotate、set的xml属性及用法

    Animation 动画详解(一)——alpha、scale、translate、rotate、set的xml属性及用法

    Android代码-SimpleRatingBar

    A RatingBar with progressive and scale animation. RotationRatingBar (contributed by nappannda) A RatingBar with progressive and rotate animation. Demo Icon made by Freepik from www.flaticon.com ...

    <Animation动画详解(三)—— 代码生成alpha、scale、translate、rotate、set及插值器动画>对应源码

    博客&lt;Animation动画详解(三)—— 代码生成alpha、scale、translate、rotate、set及插值器动画&gt;对应源码,博客地址:http://blog.csdn.net/harvic880925/article/details/40117115

    Animation Demo 源代码 (更新版)

    参考 Android动画学习Demo(1) 关于ViewAnimation的用法及总结

    Fluent Animation – An incredible animation queue system v0.8

    - Move, rotate, scale almost anything - Execute animations in parallel - Comes with 31 easing effects - Animating objects on a set of way points - Animate custom components - Animate custom fields/...

    对应源码

    博客《Animation 动画详解(一)——alpha、scale、translate、rotate、set的xml属性及用法》对应源码,博客地址:http://blog.csdn.net/harvic880925/article/details/39996643

    css3 animation transform鱼游动动画特效.zip

    meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"&gt; &lt;style&gt; body{ background-color: lightblue; overflow:hidden; ...

    Android 中 Tweened animation的实例详解

    Tweened animation有四种类型,下面主要介绍Scale类型。 运行效果如下: Android SDK提供了2种方法:直接从XML资源中读取Animation,使用Animation子类的构造函数来初始化Animation对象,第二种方法在看了Android ...

    UIAnimation:使用UIView组件轻松实现动画

    方法UIAnimation class func moveTo(point : CGPoint, duration : NSTimeInterval) -&gt; UIAnimation class func moveBy(point : CGPoint, duration : NSTimeInterval) -&gt; UIAnimation class func scaleTo(scale : ...

    View Animation Demo 源代码

    参考 View Animation 效果

    scroll-animation:根据滚动位置对元素进行动画处理

    我找不到适合我需要的npm软件包: 动画任何DOM属性的能力使用进行表演暂时挂起以最大程度地减少负载没有data-属性或特殊标签正在安装npm install scroll-animation用法const animate = require ( 'scroll-animation...

    AnimationDemo

    补间动画:渐变动画支持四种类型:平移(Translate)、旋转(Rotate)、缩放(Scale)、不透明度(Alpha);只是显示的位置变动,View的实际位置未改变,表现为View移动到其他地方,点击事件仍在原处才能响应;组合...

    Android动画例子(AnimationExample)

    Android动画例子(AnimationExample),写了四种效果 alpha 渐变透明度动画效果 scale 渐变尺寸伸缩动画效果 translate 画面转换位置移动动画效果 rotate 画面转移旋转动画效果 文章:...

    Android程序技术:19.3动画-补间动画2.pptx

    用同样的方式在anim文件夹右键选择Animation Resource File创建xml文件,再打开的对话框中录入File name录入scale_animation。;补间动画;采用同样的方式在anim文件夹右键选择Animation Resource File创建xml文件,再...

    CSS3中利用animation属性创建雪花飘落特效

    在CSS3中我们可以使用animation属性来创建复杂的动画效果,包括移动,旋转,缩放,倾斜(后几个请参考css3中的transform,scale等属性)等。而这一切,只需要我们创建关键帧(@keyframes),然后将自己想要实现的...

    Android编程之Animation动画详解

    本文实例讲述了Android编程之Animation动画用法。分享给大家供大家参考,具体如下: Animations 一、Animations介绍 Animations是一个实现android UI界面动画效果的API,Animations提供了一系列的动画效果,可以进行...

    微信小程序-微信小程序-今日头条案例

    微信小程序-今日头条案例 项目为仿今日头条,使用了百度ApiStore接口查询数据,使用微信... animation.scale(2).rotate(360).step(); animation.scale(1).step(); this.setData({ animationData : animation.export()

Global site tag (gtag.js) - Google Analytics