yourButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ShapeDrawable shapedrawable = new ShapeDrawable(); shapedrawable.setShape(new RectShape()); shapedrawable.getPaint().setColor(Color.RED); shapedrawable.getPaint().setStrokeWidth(10f); shapedrawable.getPaint().setStyle(Style.STROKE); yourButton.setBackground(shapedrawable); } });
try this, but I'm not 100% sure
source share