android - Set the width of Spinner using java not referencing any xml -


i dynamically building view here have far:

scrollview sv = new scrollview(this); linearlayout ll = new linearlayout(this); ll.setorientation(linearlayout.vertical); sv.addview(ll);       spinner s = new spinner(this); s.setid(1); list<spinnerobject> list = this.datasource.getfacilitieslist(); arrayadapter<spinnerobject> adapter = new arrayadapter<spinnerobject>(this, android.r.layout.simple_spinner_dropdown_item, list); adapter.setdropdownviewresource(android.r.layout.simple_spinner_dropdown_item); s.setadapter(adapter); ll.addview(s); setcontentview(sv); 

how set width of spinner. know how set wrap_content , set value 200dp

you can change width of in code adjusting layoutparams. example:

windowmanager.layoutparams lp = getwindow().getattributes(); lp.width = 200dp; getwindow().setattributes(lp); 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -