aaaaa

来源:互联网 发布:自制简易linux操作系统 编辑:程序博客网 时间:2024/06/01 13:18

1.

public class TweenActivity01 extends AppCompatActivity {    private ImageView iv;//    声明补间动画对象     private Animation alphaAnimation,scaleAnimation,transAnimation,rotateAnimation;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_tween01);        iv = (ImageView) findViewById(R.id.icon);        alphaAnimation = AnimationUtils.loadAnimation(this,R.anim.anim_alpha1);        alphaAnimation.setFillAfter(true);        scaleAnimation = AnimationUtils.loadAnimation(this,R.anim.anim_scale);        transAnimation = AnimationUtils.loadAnimation(this,R.anim.anim_translate);        rotateAnimation = AnimationUtils.loadAnimation(this,R.anim.anim_rotate);    }    public void onClick(View view) {        switch (view.getId()) {            case R.id.btn_alpha:                iv.startAnimation(alphaAnimation);                break;            case R.id.btn_scale:                iv.startAnimation(scaleAnimation);                break;            case R.id.btn_tranlate:                iv.startAnimation(transAnimation);                break;            case R.id.btn_rotate:                iv.startAnimation(rotateAnimation);                break;            case R.id.btn_set:                break;        }    }}



2.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical"    tools:context="com.animee.day02.TweenActivity01"    android:padding="10dp">    <Button        android:id="@+id/btn_alpha"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:text="透明度动画"        android:onClick="onClick"/>    <Button        android:id="@+id/btn_scale"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:text="缩放渐变动画"        android:onClick="onClick"/>    <Button        android:id="@+id/btn_tranlate"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:text="移动动画"        android:onClick="onClick"/>    <Button        android:id="@+id/btn_rotate"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:text="旋转动画"        android:onClick="onClick"/>    <Button        android:id="@+id/btn_set"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:text="综合动画"        android:onClick="onClick"/>    <ImageView        android:layout_width="150dp"        android:layout_height="150dp"        android:id="@+id/icon"        android:src="@mipmap/d_doge"        android:layout_gravity="center"/></LinearLayout>



2.5创建




3.

<alpha xmlns:android="http://schemas.android.com/apk/res/android"    android:fromAlpha="1"    android:toAlpha="0.1"    android:duration="8000"    android:repeatCount="1"    android:repeatMode="reverse">    <!--    定义的属性: android:fromAlpha="1" android:toAlpha="0.05"以上两个属性 取值范围 0-1 之间0:表示完全透明1:表示不透明android:duration="3000"   表示动画持续的时间 android:repeatCount="1"  表示重复的次数    0表示一次,1表示2次        android:repeatMode="reverse"   表示重复的模式    restart 表示都是重头开始                                                        reverse  表示第一次从头到尾,第二次从尾到头。    --></alpha>



4.

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



5.

<?xml version="1.0" encoding="utf-8"?><translate xmlns:android="http://schemas.android.com/apk/res/android"    android:fromXDelta="0"    android:toXDelta="200"    android:fromYDelta="0"    android:toYDelta="200"    android:duration="5000"    android:fillAfter="true"    android:interpolator="@android:anim/accelerate_interpolator"></translate>



6.

<?xml version="1.0" encoding="utf-8"?><scale xmlns:android="http://schemas.android.com/apk/res/android"    android:fromXScale="1"    android:fromYScale="1"    android:toXScale="0.5"    android:toYScale="0.5"    android:pivotX="50%"    android:pivotY="50%"    android:duration="3000"    android:fillAfter="true"    android:repeatCount="1"    android:repeatMode="restart">    <!--    定义的属性:确定开始和结束的尺寸android:fromXScale="1"android:toXScale="0.1"android:fromYScale="1"android:toYScale="0.1"确定放大缩小的中心点android:pivotX="50%"android:pivotY="50%"    --></scale>






原创粉丝点击