I’m changing Background color of a button programmatically as below
Button button =(Button)findViewById(R.id.one);
button.setBackgroundColor(0xFFFF0000);
But after this the size of button getting increased.. Im using relative layout in UI.
Default button background drawable has some kind of margins. These margins are just transparent pixels on the sides of the image. When you set background color for a button these margins disappear because the whole rectangle of the button is filled with the color.