Tint / dim drawable on touch

前端 未结 8 1662
别跟我提以往
别跟我提以往 2021-01-31 11:24

The app I\'m currently working on uses a lot of ImageViews as buttons. The graphics on these buttons use the alpha channel to fade out the edges of the button and make them look

8条回答
  •  感动是毒
    2021-01-31 11:47

    Your answer was excellent :)

    However instead of creating a button object, I am only calling an OnTouchlistener to change the state of every view.

    public boolean onTouch(View v, MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            Drawable background =  v.getBackground();
            background.setColorFilter(0xBB000000, PorterDuff.Mode.SCREEN);
            v.setBackgroundDrawable(background);
        } else if (event.getAction() == MotionEvent.ACTION_UP) {
            Drawable background =  v.getBackground();
            background.setColorFilter(null);
            v.setBackgroundDrawable(background);
        }
    
        return true;
    
    }
    

    Gives the same results though

提交回复
热议问题