The effect is looks like this:
please note:
1.The border's color vary from the original image, you can see the Gmail icon border border is black and the other icon is white. The border's color is from the original image.
2.The image have shadow
And how to implement the clicked effect ?
Rather than using setOnClickListner use setOnTouchListener to gain the desired effect
((Button)findViewById(R.id.testBth)).setOnTouchListener(new OnTouchListener() {
@Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: { Button view = (Button) v; view.getBackground().setColorFilter(0x77000000, PorterDuff.Mode.SRC_ATOP); v.invalidate(); break; } case MotionEvent.ACTION_UP: // Your action here on button click case MotionEvent.ACTION_CANCEL: { Button view = (Button) v; view.getBackground().clearColorFilter(); view.invalidate(); break; } } return true; } });
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.