android tween animation 补间动画 xml设置动画属性

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:onClick="click1"
            android:text="透明" />
        
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:onClick="click2"
            android:text="缩放" />
        
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:onClick="click3"
            android:text="旋转" />
        
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:onClick="click4"
            android:text="平移" />
        
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:onClick="click5"
            android:text="组合" />
    </LinearLayout>

    <ImageView
        android:id="@+id/image"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/ic_launcher" />

</LinearLayout>


=================================================================================================================================


<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromAlpha="1.0"
    android:toAlpha="0.2"
    android:fillAfter="true"
    android:duration="2000">
</alpha>

-----------------------------------------------------------------------------------------------

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="0"
    android:toDegrees="360"
    android:pivotX="50%"
    android:pivotY="50%"
    android:duration="2000" >
</rotate>

-----------------------------------------------------------------------------------------------

<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromXScale="0.2"
    android:toXScale="1.0"
    android:fromYScale="0.2"
    android:toYScale="1.0"
    android:pivotX="50%"
    android:pivotY="50%"
    android:duration="2000" >
</scale>

-----------------------------------------------------------------------------------------------

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromXDelta="0%p"
    android:toXDelta="50%p"
    android:fromYDelta="0%p"
    android:toYDelta="0%p"
    android:duration="2000"
    android:repeatCount="2"
    android:repeatMode="reverse" >
</translate>

-----------------------------------------------------------------------------------------------

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
    <translate
        android:duration="2000"
        android:fromXDelta="0%p"
        android:fromYDelta="0%p"
        android:repeatCount="2"
        android:repeatMode="reverse"
        android:toXDelta="50%p"
        android:toYDelta="0%p" >
    </translate>

    <scale
        android:duration="2000"
        android:fromXScale="0.2"
        android:fromYScale="0.2"
        android:pivotX="50%"
        android:pivotY="50%"
        android:repeatCount="2"
        android:repeatMode="reverse"
        android:toXScale="1.0"
        android:toYScale="1.0" >
    </scale>
</set>

=================================================================================================================================


public class MainActivity extends Activity {
private ImageView imageView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    imageView = (ImageView) findViewById(R.id.image);
}

/**
* 透明度
* 
* @param view
*/
public void click1(View view) {
    Animation animation = AnimationUtils.loadAnimation(this,R.anim.alpha_anim);
    imageView.startAnimation(animation);
}

/**
* 缩放
* 
* @param view
*/
public void click2(View view) {
    Animation animation = AnimationUtils.loadAnimation(this,R.anim.scale_anim);
    imageView.startAnimation(animation);
}

/**
* 旋转
* 
* @param view
*/
public void click3(View view) {
    Animation animation = AnimationUtils.loadAnimation(this,R.anim.rotate_anim);
    imageView.startAnimation(animation);
}

/**
* 平移
* 
* @param view
*/
public void click4(View view) {
    Animation animation = AnimationUtils.loadAnimation(this,R.anim.translate_anim);
    imageView.startAnimation(animation);
}


/**
* 组合
* 
* @param view
*/
public void click5(View view) {
    Animation animation = AnimationUtils.loadAnimation(this,R.anim.set_anim);
    imageView.startAnimation(animation);
}

}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值