package com.example.user_defined_view;android
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.AlphaAnimation;
import android.view.animation.AnimationSet;
import android.widget.ImageView;app
public class MainActivity extends Activity implements OnClickListener {
ImageView image;ide
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
image = (ImageView) findViewById(R.id.image);
image.setOnClickListener(this);
}this
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.image:
AnimationSet animset = new AnimationSet(true);
AlphaAnimation alphaanim = new AlphaAnimation(1, 0);// 徹底顯示到徹底透明
alphaanim.setDuration(3000);
animset.addAnimation(alphaanim);
image.startAnimation(animset);
break;
default:
break;
}get
}
}animation