drawable drawable_home = res.getdrawable (r.drawable.main_home_selected);//Picture
Drawable_home.setbounds (0, 0, drawable_home.getminimumwidth (), Drawable_home.getminimumheight ());//Set margin
Home_bt.setcompounddrawables (NULL, drawable_home, NULL, NULL);//Set the picture in button buttons
Formatting the buttons in a layout
<style name= "Main_bottom_style" parent= "Base_wrap_style" >
<item name= "Android:layout_width" >0dp</item>
<item name= "Android:layout_height" >wrap_content</item>
<item name= "Android:layout_weight" >1</item>
<item name= "Android:paddingtop" >5dp</item>
<item name= "Android:paddingbottom" >5dp</item>
<item name= "Android:gravity" >center</item>
<item name= "Android:textsize" >12sp</item>
<item name= "Android:background" > @null </item>
<item name= "Android:textcolor" > @color/white</item>
<item name= "Android:drawablepadding" >2dp</item>
</style>
<button
Android:id= "@+id/main_hot_bt"
style= "@style/main_bottom_style"
android:drawabletop= "@drawable/main_hot_unselected"
android:text= "@string/main_hot"/>