Android examples for User Interface:View Click
add View Click Right Effect
//package com.java2s; import android.graphics.PorterDuff; import android.view.MotionEvent; import android.view.View; public class Main { public static void addClickRightEffect(View view) { view.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: { v.getBackground().setColorFilter(0x55FFFF00, PorterDuff.Mode.SRC_ATOP); v.invalidate();/*from w w w .jav a 2 s . c om*/ return true; } case MotionEvent.ACTION_UP: { v.getBackground().clearColorFilter(); v.invalidate(); v.performClick(); return false; } } return false; } }); } }