RadioGroup extending RelativeLayout?

You need to get the RadioGroup's source code from here, replace all entries of LinearLayout with RelativeLayout.

Add this code to some xml file in your project (usually its name is attrs.xml):

<resources>
    <declare-styleable name="RadioGroup">
        <attr name="android:checkedButton" />
    </declare-styleable>
</resources>

Replace RadioGroup's constructors with these:

public RadioGroup(Context context) {
    super(context);
    if (!isInEditMode()) {
        init();
    }
}

public RadioGroup(Context context, AttributeSet attrs) {
    super(context, attrs);
    if (!isInEditMode()) {
        TypedArray attributes = context.obtainStyledAttributes(
                attrs, R.styleable.RadioGroup, 0,
                android.R.style.Widget_CompoundButton_RadioButton);

        int value = attributes.getResourceId(R.styleable.RadioGroup_checkedButton,
            View.NO_ID);
        if (value != View.NO_ID) {
            mCheckedId = value;
        }

        attributes.recycle();
        init();
    }
}

Remove the following constructor from the LayoutParams inner class:

public LayoutParams(int w, int h, float initWeight) {
    super(w, h, initWeight);
}

Replace all occurrences of setOnCheckedChangeWidgetListener() method calls with the setOnCheckedChangeListener() method. IMPORTANT: In this case it won't be possible to use this method from a code that uses this widget.

Haven't tried this but hope this will work.


Copy the source for RadioGroup from here and edit it to change it to extend RelativeLayout instead of LinearLayout.