`
huakewoniu
  • 浏览: 47653 次
  • 性别: 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" 提供了一个开源项目,旨在帮助开发者快速且高效地调整动画的时长比例,从而实现平滑、美观的动画过渡。这个项目名为 "AnimatorDurationScale",它通过调整系统默认的...

    Android Animation Demo

    2. **Scale Animation**(缩放动画):改变视图的大小。`fromXScale`和`toXScale`控制水平方向的缩放,`fromYScale`和`toYScale`控制垂直方向的缩放。 3. **Rotate Animation**(旋转动画):让视图绕着某个点旋转...

    Animation Demo 试用示例

    2. **缩放动画(Scale Animation)**: 缩放动画用于改变视图的大小,通过`fromXScale`、`toXScale`、`fromYScale`和`toYScale`属性设定初始和结束的缩放比例。这可以用于实现物体放大或缩小的效果,如图片点击后的...

    Android的Animation和Activity Animation例子

    - **Scale Animation**(缩放动画):Activity大小的变化。 - **Fade Animation**(淡入淡出动画):Activity的透明度变化。 - **Zoom Animation**(缩放动画):Activity的大小和透明度同时变化。 例如,要为启动...

    animation.zip

    最后,缩放动画(Scale Animation)改变View的大小。XML的`scale`标签允许我们设置`fromXScale`、`toXScale`、`fromYScale`和`toYScale`来控制水平和垂直方向的缩放比例。代码中,`ScaleAnimation`类对应地创建缩放...

    android animation 动画

    3. **缩放动画(Scale Animation)** `ScaleAnimation`类用于改变视图的大小,它可以按比例放大或缩小视图。通过设置初始和结束的x轴和y轴的缩放因子,可以实现视图的拉伸或收缩效果,这对于创建弹出框展开或关闭的...

    android_animation

    "android_animation"这个主题主要聚焦于Android中的View动画,这包括了转换动画(Translation Animation)、缩放动画(Scale Animation)、旋转动画(Rotation Animation)以及平移动画(Alpha Animation)。...

    AndroidView中添加Animation.zip

    4. **Scale Animation**:改变视图的大小,可以按比例缩放。适用于放大或缩小按钮、图片等元素。 应用视图动画的基本步骤包括: 1. 创建`Animation`对象,如`AlphaAnimation`、`TranslateAnimation`等。 2. 设置...

    android animation实例

    视图动画主要包含透明度动画(Alpha Animation)、平移动画(Translate Animation)、旋转动画(Rotate Animation)和缩放动画(Scale Animation)。在"guolin_AnimationTest"中,你可能会看到这些动画的实现,例如...

    android之animation(一)

    视图动画主要包括Translation Animation(平移动画)、Scale Animation(缩放动画)、Rotation Animation(旋转动画)和Alpha Animation(透明度动画)。这些动画可以通过XML定义或在代码中动态创建。例如,...

    android实现animation

    - Scale Animation(缩放动画):调整视图的尺寸,可以放大或缩小。 - Rotation Animation(旋转动画):让视图绕一个轴旋转。 实现视图动画通常通过XML定义动画资源,并在代码中加载和应用,或者直接在代码中...

    Animation动画

    缩放动画(Scale Animation) - **定义**:改变视图的尺寸大小。 - **参数说明**: - `fromX/toX/fromY/toY`:缩放的比例。 - `pivotXType/pivotYType`:缩放中心点的类型。 - `pivotXValue/pivotYValue`:缩放...

    android应用源码动画效果-translate、scale、alpha、rotate-切换Activity动画.zip

    2. **Scale Animation(缩放动画)** Scale动画用于改变对象的大小,可以同时调整宽度和高度。在Activity切换场景中,可以用来实现Activity缩小或放大消失或出现的效果。通过`setFromXValue()`和`setToXValue()`...

    android应用源码动画 translate、scale、alpha、rotate 切换动画-IT计算机-毕业设计.zip

    2. **Scale Animation(缩放动画)**: 缩放动画改变对象的大小,可以使其放大或缩小。在XML中,使用`&lt;scale&gt;`标签定义,`fromXScale`和`toXScale`控制x轴方向的缩放比例,`fromYScale`和`toYScale`是y轴的。例如,...

    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 ...

    Android动画效果编程基础

    - **尺寸伸缩动画(Scale Animation)**:通过改变视图的尺寸大小来实现动画效果。 - **位置移动动画(Translate Animation)**:通过改变视图的位置来实现动画效果。 - **旋转动画(Rotate Animation)**:通过旋转...

    转载:Andorid小項目之--Animation四種動畫的圖片效果(附源碼)

    3. 缩放动画(Scale Animation) 缩放动画可以改变视图的大小。`&lt;fromXScale&gt;`和`&lt;toXScale&gt;`定义x轴方向上的缩放比例,`&lt;fromYScale&gt;`和`&lt;toYScale&gt;`控制y轴。例如,让一个图片逐渐放大两倍: ```xml &lt;scale xmlns...

    安卓属性的动画,改变大小,动态消失

    二、改变大小(Scale Animation) 要实现对象大小的变化,我们可以使用`ObjectAnimator`类。首先,我们需要获取要动画化的对象,然后设置动画的目标属性。例如,我们可以用以下代码让一个视图先放大再缩小: ```...

    android渐变动画及缩放,模仿点赞效果

    本例中,我们主要讨论视图动画,特别是渐变动画(Alpha Animation)和缩放动画(Scale Animation)。 2. **Alpha Animation**:这种动画主要用于改变View的透明度。通过设置动画的`alpha`属性,我们可以让一个元素...

    动画animations

    这四种动画包括了平移动画(Translate Animation)、旋转动画(Rotate Animation)、缩放动画(Scale Animation)以及淡入淡出动画(Alpha Animation)。接下来,我们将详细解析每种动画的实现方法。 1. 平移动画...

Global site tag (gtag.js) - Google Analytics