Basic Ideas:
Method 1. the mask can directly overlay a pure white or black View with alpha, and can directly overlay the FrameLayout layer in the ImageView coat. Its foreground (generally, you may only know the background, but framelayout and foreground) specify a selector (0x33000000 when pressed, that is,) in place.
Method 2: override imageView. When the status changes, invalidate (triggers onDraw), and 0x33000000 is drawn in onDraw Based on the status. Note that dispatchSetPressed can be triggered only when imageView. setClickable (true) or imageView. setOnClickListener is used.
@ Overridepublic void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. activity_main); // obtain the id // imgTest = (ImageView) findViewById (R. id. imgTest); loMain = (RelativeLayout) findViewById (R. id. loMain); findViewById (R. id. btn1 ). setOnClickListener (this); findViewById (R. id. btn2 ). setOnClickListener (this); MyImg myImg = new MyImg (this); myImg. setImageResource (R. drawable. meinv); myImg. setClickable (true); loMain. addView (myImg);} private class MyImg extends ImageView {public MyImg (Context context) {super (context) ;}@ Overrideprotected void onDraw (Canvas canvas) {// TODO Auto-generated method stubsuper. onDraw (canvas); if (isPressed () canvas. drawColor (0x33000000);} @ Overrideprotected void dispatchSetPressed (boolean pressed) {// TODO Auto-generated method stubsuper. dispatchSetPressed (pressed); invalidate ();}}