Android examples for Animation:Alpha Fly Animation
add Touch Dark Animation
//package com.java2s; import android.graphics.ColorMatrixColorFilter; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; import android.widget.ImageView; public class Main { public static final OnTouchListener VIEW_TOUCH_DARK = new OnTouchListener() { public final float[] BT_SELECTED = new float[] { 1, 0, 0, 0, -50, 0, 1, 0, 0, -50, 0, 0, 1, 0, -50, 0, 0, 0, 1, 0 }; public final float[] BT_NOT_SELECTED = new float[] { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0 }; @Override/*from w ww .j a v a 2 s . c o m*/ public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { if (v instanceof ImageView) { ImageView iv = (ImageView) v; iv.setColorFilter(new ColorMatrixColorFilter( BT_SELECTED)); } else { v.getBackground().setColorFilter( new ColorMatrixColorFilter(BT_SELECTED)); v.setBackgroundDrawable(v.getBackground()); } } else if (event.getAction() == MotionEvent.ACTION_UP) { if (v instanceof ImageView) { ImageView iv = (ImageView) v; iv.setColorFilter(new ColorMatrixColorFilter( BT_NOT_SELECTED)); } else { v.getBackground().setColorFilter( new ColorMatrixColorFilter(BT_NOT_SELECTED)); v.setBackgroundDrawable(v.getBackground()); } } return false; } }; public static void addTouchDark(View view, boolean isClick) { view.setOnTouchListener(VIEW_TOUCH_DARK); if (!isClick) { view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { } }); } } }