• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps MaskFilter to a button?

Hi,

I'm trying to apply a Mask or Blur Filter to some buttons at runtime... This button is reflecting a "layer" object, so I'd like to blur its edges to reflect how transparent is this layer...
I'm able to set a ColorFilter, or apply a maskFIlter to its TextView, but cant figure how to apply a maskFilter to the whole button...
here is the part of my code where I'd like to apply this filter (in a applyFilter method):
Code:
public void createList(LinearLayout lm) {
        lm.removeAllViews();
        for (int i = 0; i < kwang07Android.nblayers; i++) {
            final Button newbtn = new Button(this, null, android.R.attr.buttonStyleSmall);
            int col = kwang07Android.layers[i].col;
            int newColor = Color.argb(156+(int)(kwang07Android.layers[i].opacite*100), Color.red(col), Color.green(col), Color.blue(col));
            newbtn.getBackground().setColorFilter(newColor, MULTIPLY);
            applyFilter(newbtn, i, BlurMaskFilter.Blur.INNER);
            newbtn.setText("couche " + Integer.toString(i));
            newbtn.setId(i);
            newbtn.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,30+kwang07Android.layers[i].thickness/20));
            final int finalI = i;
            newbtn.setOnTouchListener(new Button.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if (event.getAction() == MotionEvent.ACTION_DOWN) {
                        showColorPickerDialogDemo(newbtn, finalI);
                    }
                    return false;
                }
            });
            lm.addView(newbtn);
        }
...
Any advice?

Thanks.
 
Back
Top Bottom