Android开场透明度渐变动画

mainfest.xml清单文件

  <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.ssss.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            intent-filter>
        activity>
    application>
manifest>

MainActivity文件如下


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ImageView vv=(ImageView) findViewById(R.id.renwu); //查找图片
        Animation ani=AnimationUtils.loadAnimation(this,R.anim.touming); //申明一个动画
        vv.setAnimation(ani);//为图片绑定动画
        ani.setAnimationListener(new AnimationListener() {  //单纯的对动画做监听

            @Override
            public void onAnimationStart(Animation arg0) {
                // TODO Auto-generated method stub      
            }

            @Override
            public void onAnimationRepeat(Animation arg0) {
                // TODO Auto-generated method stub  
            }           
            @Override
            public void onAnimationEnd(Animation arg0) { //动画结束时,干什么
                // TODO Auto-generated method stub
                Log.i("haihai", "doinghuajieshu");
            }
        });
    }

Android开场透明度渐变动画_第1张图片



<alpha xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromAlpha="0"
    android:toAlpha="1"
    android:duration="4000"
    android:interpolator="@android:anim/accelerate_interpolator">
alpha>

Android开场透明度渐变动画_第2张图片



FR:海涛高软(QQ技术群:386476712)

你可能感兴趣的:(Android)