单选按钮设置布局参数在添加到单选组时不起作用

radiobutton set layoutparams do not work when be add to radiogroup

 val param =  LinearLayout.LayoutParams(WRAP_CONTENT,WRAP_CONTENT)
        param.rightMargin = 100

        val rb = RadioButton(this)
        rb.text = "1"
        rb.setTextColor(Color.parseColor("#ffffff"))
        rb.layoutParams = param

        rgroup.addView(rb)

        val rb2 = RadioButton(this)
        rb2.text = "2"
        rb2.setTextColor(Color.parseColor("#ffffff"))
        rb2.layoutParams = param
        rgroup.addView(rb2)

先给rb设置layoutparams然后加入radiogroup,运行 in android M时右边距不起作用,但在M上有效,是版本差异导致的吗?相同的代码,不同的结果

使用RadioGroup.LayoutParams代替LinearLayout.LayoutParams