Pregunta

Quiero hacer algo así como este programatáticamente -

<LinearLayout>
  <RelativeLayout1 weight = 1>
  <RelativeLayout2 weight = 3>
  <RelativeLayout3 weight = 1>
<LinearLayout>

No me permite hacer un ajuste programáticamente.Sin embargo, sí veo que Relativelyout tiene un parámetro Android: Layout_weight en XML.¿Me estoy perdiendo algo?

¿Fue útil?

Solución

Cuando agrega el Relativelyout al LineArlayout usando AddView tiene que proporcionar un LineAterioreut.LayoutParams, algo así:

LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(width, height, weight);
linearLayout.addView(relativeLayout, params);

Referencia aquí

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top