glass scale centering

This commit is contained in:
oxidiert
2025-10-10 12:35:29 +02:00
parent 5570710da5
commit 4089841336

View File

@ -162,21 +162,26 @@ class HandlerGlassScaleQuestion(
val radioGroup = RadioGroup(context).apply { val radioGroup = RadioGroup(context).apply {
orientation = RadioGroup.HORIZONTAL orientation = RadioGroup.HORIZONTAL
layoutParams = TableRow.LayoutParams(0, TableRow.LayoutParams.WRAP_CONTENT, 5f) layoutParams = TableRow.LayoutParams(0, TableRow.LayoutParams.WRAP_CONTENT, 5f)
setPadding(0, 0, 0, 0)
} }
// RadioButtons sind direkte Kinder der RadioGroup!
scaleLabels.forEach { labelKey -> scaleLabels.forEach { labelKey ->
val cell = FrameLayout(context).apply {
layoutParams = RadioGroup.LayoutParams(0, RadioGroup.LayoutParams.WRAP_CONTENT, 1f)
}
val rb = RadioButton(context).apply { val rb = RadioButton(context).apply {
tag = labelKey tag = labelKey
id = View.generateViewId() id = View.generateViewId()
isChecked = savedLabel == labelKey isChecked = savedLabel == labelKey
setPadding(0, 0, 0, 0) setPadding(0, 0, 0, 0)
} }
val lp = RadioGroup.LayoutParams( rb.layoutParams = FrameLayout.LayoutParams(
0, RadioGroup.LayoutParams.WRAP_CONTENT, 1f FrameLayout.LayoutParams.WRAP_CONTENT,
).apply { gravity = Gravity.CENTER } FrameLayout.LayoutParams.WRAP_CONTENT,
rb.layoutParams = lp Gravity.CENTER
radioGroup.addView(rb) )
cell.addView(rb)
radioGroup.addView(cell)
} }
row.addView(radioGroup) row.addView(radioGroup)
@ -184,6 +189,7 @@ class HandlerGlassScaleQuestion(
} }
} }
override fun validate(): Boolean { override fun validate(): Boolean {
val table = layout.findViewById<TableLayout>(R.id.glass_table) val table = layout.findViewById<TableLayout>(R.id.glass_table)
for (i in 0 until table.childCount) { for (i in 0 until table.childCount) {