i'm using Buttons (or ImageButtons) to show the icons of my app. I use this to set the state of the buttons, with a image for the button pressed and another image for the button unpressed:
selector(this, favorites, R.drawable.icon_star_mark, R.drawable.icon_star_mark_selected);
public static void selector(Context c, Button b, int normal_image, int pressed_image){
StateListDrawable states = new StateListDrawable();
states.addState(new int[] {android.R.attr.state_pressed}, c.getResources().getDrawable(pressed_image));
states.addState(new int[] { }, c.getResources().getDrawable(normal_image));
b.setBackgroundDrawable(states);
}
I need to put text below the icon, but i want to learn doing it without using a LinearLayout with a icon and a textview below it. I want to learn doing that if it is possible to achiev it.
This is the way i'm creating the icon:
Button map= new Button(this);
selector(this, map, R.drawable.icon_map, R.drawable.icon_map_selected);
map.setText("Map");
The problem is that the text is being displayed above the icon, and not below the icon.
It is possible to achieve that with java code? (placing the text of the icon below the icon without using a linear layout with a textview below the icon)
Thanks in advance