Android two rows of Radio Buttons

This tutorial shows how to add two rows of radio buttons.

  1. Add Gradle dependency:
implementation 'androidx.gridlayout:gridlayout:1.0.0'

2. Add utility class to support two rows. Copy and paste below into your project. Then you will call the class in your xml.

package utility

import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.view.ViewGroup
import android.view.accessibility.AccessibilityEvent