/* 取得Animation定义在res/anim目录下 */ |
myAnimation = AnimationUtils.loadAnimation( this , R.anim.my_anim); |
/* 将mySpinner加入OnTouchListener */ |
mySpinner.setOnTouchListener( new Spinner.OnTouchListener() { |
@Override |
public boolean onTouch(View v, MotionEvent event) { |
/* 将mySpinner执行Animation */ |
v.startAnimation(myAnimation); |
/* 将mySpinner隐藏 */ |
v.setVisibility(View.INVISIBLE); |
return false ; |
} |
}); |
<?xml version= "1.0" encoding= "utf-8" ?> |
<set xmlns:android= "http://schemas.android.com/apk/res/android" > |
<translate |
android:duration= "300" |
android:fromXDelta= "0" |
android:toXDelta= "-100%p" > |
</translate> |
<alpha |
android:duration= "300" |
android:fromAlpha= "1.0" |
android:toAlpha= "0.0" > |
</alpha> |
</set> |