Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2093162
  • 博文数量: 413
  • 博客积分: 10926
  • 博客等级: 上将
  • 技术积分: 3862
  • 用 户 组: 普通用户
  • 注册时间: 2006-01-09 18:14
文章分类

全部博文(413)

文章存档

2015年(5)

2014年(1)

2013年(5)

2012年(6)

2011年(138)

2010年(85)

2009年(42)

2008年(46)

2007年(26)

2006年(59)

分类: 嵌入式

2011-04-01 12:01:40

  1. Docs
    1. Animation Basic
      http://developer.android.com/guide/topics/resources/animation-resource.html
    2. Property Animation
      • http://developer.android.com/guide/topics/resources/animation-resource.html#Property
      • http://developer.android.com/guide/topics/graphics/animation.html
    3. Tween Animation - View Animation
      • http://developer.android.com/guide/topics/resources/animation-resource.html#Tween
      • http://developer.android.com/guide/topics/graphics/view-animation.html#tween-animation
    4. Frame Animation - View Animation
      • http://developer.android.com/guide/topics/resources/animation-resource.html#Frame
      • http://developer.android.com/guide/topics/graphics/view-animation.html#frame-animation
    5. xxx
  2. View Animation
    You can use View Animation in any View object to perform tweened animation and frame by frame animation.

    • ViewGroup Animation - create animation in code.
      (Sample: ApiDemo > Views > Layout Animation)

      Precedure:
      • Create Animation/AnimationSet

        AnimationSet set = new AnimationSet(true);
        Animation animation = new AlphaAnimation(0.0f, 1.0f);
        animation.setDuration(50);
        set.addAnimation(animation);

        animation = new TranslateAnimation(
                    Animation.RELATIVE_TO_SELF, 0.0f,Animation.RELATIVE_TO_SELF, 0.0f,
                    Animation.RELATIVE_TO_SELF, -1.0f,Animation.RELATIVE_TO_SELF, 0.0f
                    );
        animation.setDuration(100);
        set.addAnimation(animation);

      • Construct animation controller
        LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f);

      • Set animation
        ListView listView = getListView();       
        listView.setLayoutAnimation(controller);   
           
    • ViewGroup Animation - Specify animation in resource file.
      • Define view animation
        For ListView: slide_right.xml

                        android:duration="@android:integer/config_shortAnimTime" />


        For GridView: fade.xml
               android:interpolator="@android:anim/accelerate_interpolator"
               android:fromAlpha="0.0" android:toAlpha="1.0"
               android:duration="@android:integer/config_longAnimTime" />

      • Define layoutAnimation
        (You can find all available attributes of layoutAnimation/gridLayoutAnimation in android.R.styleable)

        For ListView: layout_bottom_to_top_slide.xml
                android:delay="30%"
                android:animationOrder="reverse"
                android:animation="@anim/slide_right" />

        For GirdView: layout_grid_fade.xml
                android:rowDelay="50%"
                android:directionPriority="column"
                android:animation="@anim/fade" />
      • Use layoutAnimation
        For ListView:
            android:id="@android:id/list"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layoutAnimation="@anim/layout_bottom_to_top_slide" />

        For GridView:
            android:layoutAnimation="@anim/layout_grid_fade"

            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:padding="10dp"
            android:verticalSpacing="10dp"

            android:horizontalSpacing="10dp"
            android:numColumns="auto_fit"
            android:columnWidth="60dp"
            android:stretchMode="columnWidth"

            android:gravity="center" />



    • xxx
  3. Property Animation
    Introduced in Android 3.0, the property animation system allows you to animate almost anything (Views and non-Views). You can define an animation to change any object property (a field in an object, such as position property x of view) over time, regardless of whether it draws to the screen or not.
  4. Activity Animation
    Start target activity in an activity subclass as following:
    startActivity(intent);
    overridePendingTransition(R.anim.xxx, R.anim.xxx);
  5. xxx
阅读(920) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~