您的位置:首页 > 产品设计 > UI/UE

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

2015-10-01 19:57 543 查看
放动画效果,可以使用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" />


代码 :

@Override
public 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>


效果:



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: