2

How to highlight a Bitmap? Like Google play.

enter image description hereenter image description here

My images are in a server, so I´d like to not download two images to make this effect.

What I have tried:

I just try to use Layers but it don't make a transparent highlight effect. The Bitmap is set on an Imagebutton.

Maybe canvas should work, creating a drawable transparent with a light color, I tried some codes but doesn't work or its because I don't know how to handle this.

BitmapDrawable bitmapDrawable = new BitmapDrawable(bitmap);

                    Drawable[] layers = new Drawable[2];
                    layers[0] = bitmapDrawable;
                    layers[1] = r.getDrawable(R.drawable.default_button_pressed);
                    LayerDrawable layerDrawable = new LayerDrawable(layers);
                    imageView.setImageDrawable(layerDrawable);

default_button_pressed

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
     android:shape="rectangle">
    <corners android:radius="3dp" />
    <gradient android:endColor="#FFFFFF" android:startColor="#ccffff" android:angle="90" />
    <stroke android:width="1dp" android:color="#33364252" />

</shape>
4

2 回答 2

2

尝试使用ColorFilter

Imagebutton.setColorFilter(0x808fd2ea);
于 2013-01-07T17:11:12.053 回答
1

易于OnTouchListener使用的方法和使用setColourFilter方法ImageButton

  ImageButton aButton = (ImageButton) findViewById(R.id.MY_IMAGEBUTTON_ID);
   aButton.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent me) {
            ImageButton button = (ImageButton)v;
            if (me.getAction() == MotionEvent.ACTION_DOWN) {
                button.setColorFilter(Color.BLUE);
                return true;
            } else if (me.getAction() == MotionEvent.ACTION_UP) {
                button.setColorFilter(null);
                return true;
            }
            return false;
        }

    });
于 2013-01-07T17:19:04.983 回答