Set Button background

by / Monday, 05 August 2013 / Published in Android

A button consists of text or an icon (or both text and an icon) that communicates what action occurs when the user touches it.To customize individual buttons with a different background, specify the android:background attribute with a drawable or color resource.

This code is for setting background image of a button and set background color of a layout.

Code:

linearLayoutParent.setBackgroundColor(Color.BLUE); //layout background is set
addButton.setBackgroundResource(R.drawable.add_btn);//button background is set

TOP