Programmatically set ImageButton layout_gravity

view story

http://stackoverflow.com – What I Tried To Do I tried to set my ImageButton's layout_gravity via Java code, the way I want the ImageButton to be is presented like the way within the Orange frame in the image below: The Blue frame is a vertical LinearLayout act as a "base" layout and this is the layout I tried to add child layouts to. The Orange and Red are both horizontal LinearLayout. The Orange layout is the way I want to put the ImageButton and the TextView, this one is set up via XML The Red layout is the result I tried to mimic the Orange layout via Java code. The Related Code Here's the XML code that set (HowTos)