Отказ от ответственности: AFAIK На этот вопрос пока нет ответа для XAMARIN ANDROID . На него ответили несколько раз для Android / Java .
Моя проблема в том, что у меня нет перегрузки конструктора для GridLayoutParams, которая принимает layout_weight в качестве параметра ...
Ниже приведен XML-код, который я пытаюсь воспроизвести по коду:
android:layout_width="0sp"
android:layout_height="wrap_content"
android:layout_weight="1"
Отсутствие установки layout_weight делает элемент управления (флажок) просто невидимым.
Вот где я с кодом Xamarin для Android:
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;
Любая помощь приветствуется.