How to change the Style of a button dynamically in android?

By | March 23, 2013

Here I am going to change the style of a default button to buttonStyleSmall. So after that the button will appear small.

this simple code does this.

Button myButton = new Button(context, null, android.R.attr.buttonStyleSmall);

The try this adding to a layout

RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
rLayout.addView(rightButton, lp);

Leave a Reply

Your email address will not be published. Required fields are marked *