user interface - Set attributes (margin, gravity, etc...) to an Android view programmatically (without XML) -


i need create gui (layout+views) in .java activity class (i know it's far more flexible , easier use .xml layout file, don't want use now).

i can't find setgravity() (but "gravity" object can't figure how use) or set setmargin() method "view" object.

what easiest way ?

thanx.

for setting margin on component. following leaves existing margins set , sets left margin zero.

textview title = ((textview)findviewbyid(r.id.default_panel_title)) final viewgroup.marginlayoutparams lpt =(marginlayoutparams)title.getlayoutparams();  lpt.setmargins(0,lpt.topmargin,lpt.rightmargin,lpt.bottommargin);  title.setlayoutparams(lpt); 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -