Disclaimer: AFAIK This question has no answer so far for XAMARIN ANDROID. It has been answered multiple times for Android/Java.
My problem is that I have no constructor overload for GridLayoutParams that takes the layout_weight as a parameter...
The following is the XML I'm trying to replicate by code:
android:layout_width="0sp"
android:layout_height="wrap_content"
android:layout_weight="1"
Not setting layout_weight makes the control (a checkbox) simply invisible.
Here is where I am with the Xamarin Android code:
CheckBox cb = new CheckBox(this);
cb.Id = View.GenerateViewId();
GridLayout.LayoutParams cbButtonLayoutParams = new GridLayout.LayoutParams();
cbButtonLayoutParams.RowSpec = GridLayout.InvokeSpec(row, 1); // Setting row and rowspan respectivly
cbButtonLayoutParams.ColumnSpec = GridLayout.InvokeSpec(column, 1); // Setting col and colspan respectivley
cbButtonLayoutParams.Width = 0;
cbButtonLayoutParams.Height = GridLayout.LayoutParams.WrapContent;
cbButtonLayoutParams.SetGravity(GravityFlags.Center);
// How do I set the weight ? There is no property nor constructor...
// cbButtonLayoutParams.???
cb.LayoutParameters = cbButtonLayoutParams;
Any help appreciated.