AndroidUI 视图动画-缩放动画效果 (ScaleAnimation)

来源:互联网 发布:龙腾管家软件下载 编辑:程序博客网 时间:2024/06/05 08:07

放动画效果,可以使用ScaleAnimation;

    <Button        android:id="@+id/btnScale2"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:layout_below="@+id/btnScole"        android:layout_centerHorizontal="true"        android:layout_marginTop="77dp"        android:text="@string/btnScale2" />

代码 :

@Overridepublic void onClick(View v) {//从相对位置 的起点开始缩放动画//ScaleAnimation scale=new ScaleAnimation(0, 1, 0,1);//从相对位置的100px x 100px的位置开始动画//ScaleAnimation scale=new ScaleAnimation(0, 1, 0,1,100,100);//从按钮自身的中心点开始缩放动画//ScaleAnimation scale=new ScaleAnimation(0, 1, 0,1,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);//scale.setDuration(2000);//v.startAnimation(scale);//使用XML配置缩放动画v.startAnimation(AnimationUtils.loadAnimation(v.getContext(), R.anim.scale2));}});

XML:



<scale xmlns:android="http://schemas.android.com/apk/res/android"    android:fromXScale="0"     android:toXScale="1"     android:fromYScale="0"    android:toYScale="1"    android:pivotX="50%"     android:pivotY="50%"    android:duration="2000"></scale>


效果:



0 0