SofteemConsultancyServiceSofteemConsultancyServiceAndroid用户界面(UI)组件3G手机Android系统开发系列课件4SofteemConsultancyService2020/2/7Animation渐变透明度动画效果渐变尺寸伸缩动画效果画面转换位置移动效果画面转换旋转动画效果SofteemConsultancyService2020/2/7渐变透明度动画效果更改视图组件的透明度效果,可以使得视图组件产生一种忽明忽暗的感觉,从无到有,从有到无。SofteemConsultancyService2020/2/7渐变透明度动画效果LinearLayoutxmlns:android=:orientation=verticalandroid:layout_width=fill_parentandroid:layout_height=fill_parentImageViewandroid:id=@+id/imageview01android:layout_width=wrap_contentandroid:layout_height=wrap_contentandroid:src=@drawable/a11/ImageView/LinearLayoutSofteemConsultancyService2020/2/7渐变透明度动画效果-配置文件•setxmlns:android=•alpha•android:fromAlpha=0.0•android:toAlpha=1.0•android:duration=3000/alpha•/setSofteemConsultancyService2020/2/7渐变透明度动画效果•@Override•protectedvoidonCreate(BundlesavedInstanceState){•super.onCreate(savedInstanceState);•setContentView(R.layout.main);•Animationanim=AnimationUtils.loadAnimation(this,R.anim.alpha);•findViewById(R.id.imageview01).startAnimation(anim);•}SofteemConsultancyService2020/2/7渐变尺寸伸缩动画效果更改视图组件的尺寸,可以使得视图组件放大或缩小,产生由大到小,由小到大的过程。SofteemConsultancyService2020/2/7渐变尺寸伸缩动画效果LinearLayoutxmlns:android=:orientation=verticalandroid:layout_width=fill_parentandroid:layout_height=fill_parentImageViewandroid:id=@+id/imageview02android:layout_width=wrap_contentandroid:layout_height=wrap_contentandroid:src=@drawable/a11/ImageView/LinearLayoutSofteemConsultancyService2020/2/7渐变尺寸伸缩动画效果-配置文件•setxmlns:android=•scale•android:interpolator=@android:anim/accelerate_decelerate_interpolator•android:fromXScale=0.0•android:toXScale=1.4•android:fromYScale=0.0•android:toYScale=1.4•android:pivotX=50%•android:pivotY=50%•android:duration=700/scale•/setSofteemConsultancyService2020/2/7渐变尺寸伸缩动画效果•@Override•protectedvoidonCreate(BundlesavedInstanceState){•super.onCreate(savedInstanceState);•setContentView(R.layout.main);•Animationanim=AnimationUtils.loadAnimation(this,R.anim.scale);•findViewById(R.id.imageview02).startAnimation(anim);•}SofteemConsultancyService2020/2/7画面转换位置移动动画效果除了可以改变视图组件的透明度和大小以外,还可以更改视图组件所显示的位置,可以使得视图组件在页面上任意位置显示,以达到移动效果。SofteemConsultancyService2020/2/7画面转换位置移动动画效果LinearLayoutxmlns:android=:orientation=verticalandroid:layout_width=fill_parentandroid:layout_height=fill_parentTextViewandroid:id=@+id/textview01android:layout_width=wrap_contentandroid:layout_height=wrap_contentandroid:text=@string/hello/ImageView/LinearLayoutSofteemConsultancyService2020/2/7画面转换位置移动动画效果-配置文件•setxmlns:android=•translate•android:fromXDelta=30•android:toXDelta=-80•android:fromYDelta=30•android:toYDelta=300•android:duration=2000/translate•/setSofteemConsultancyService2020/2/7画面转换位置移动动画效果•@Override•protectedvoidonCreate(BundlesavedInstanceState){•super.onCreate(savedInstanceState);•setContentView(R.layout.main);•Animationanim=AnimationUtils.loadAnimation(this,R.anim.translate);•findViewById(R.id.textview01).startAnimation(anim);•}SofteemConsultancyService2020/2/7画面转换旋转动画效果在很多动画效果当中,旋转效果也是常用的一种,它可以让某个视图组件按照某一个方向进行旋转。SofteemConsultancyService2020/2/7画面转换旋转动画效果LinearLayoutxmlns:android=:orientation=verticalandroid:layout_width=fill_parentandroid:layout_height=fill_parentTextViewandroid:id=@+id/textview02android:layout_width=wrap_contentandroid:layout_height=wrap_contentandroid:text=@string/hello/ImageView/LinearLayoutSofteemConsultancyService2020/2/7画面转换旋转动画效果-配置文件•setxmlns:android=•rotate•android:interpolator=@android:anim/accelerate_decelerate_interpolator•android:fromDegrees=0•android:toDegrees=+360•android:duration=10000/rotate•/setSofteemConsultancyService2020/2/7画面转换旋转动画效果•@Override•protectedvoidonCreate(BundlesavedInstanceState){•super.onCreate(savedInstanceState);•setContentView(R.layout.main);•Animationanim=AnimationUtils.loadAnimation(this,R.anim.rotate);•findViewById(R.id.textview02).startAnimation(anim);•}