I need to create a spinner by programming code and define:
- layout_height: match_parent
- layout_weight: 10
- layout_width: wrap_content
Spinner sp = new Spinner (this);
sp.Layout_height ???
I need to create a spinner by programming code and define:
Spinner sp = new Spinner (this);
sp.Layout_height ???
To programmatically change the size of a view use LayoutParameters
.
Example:
LinearLayout.LayoutParams parametros = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.MatchParent, 10);
Spinner sp = new Spinner(this);
sp.LayoutParameters = parametros;
Remembering that this constructor has the following signature: LayoutParams(int width, int height, int weight)
Or if you prefer you can do this:
Spinner sp = new Spinner(this);
LinearLayout.LayoutParams parametros = (LinearLayout.LayoutParams)sp.LayoutParameters;
parametros.Height = LinearLayout.LayoutParams.MatchParent;
parametros.Width = LinearLayout.LayoutParams.WrapContent;
parametros.Weight = 10;
I hope I have helped.