简体   繁体   中英

create divider between radio buttons in radio group added programmatically?

i have created radio buttons added to radio group programmatically, the radio group in xml is as below

<RadioGroup
android:layout_width="match_parent"
android:id="@+id/rgFeedbacks"
android:orientation="vertical"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding"
android:paddingStart="@dimen/appbar_padding"
android:divider="@color/radiogroup_divider"

and the radio buttons are added like below

 for(int i=0; i<array.size(); i++){
        rb[i]  = new RadioButton(this);
        rb[i].setId(i);
        rb[i].setText(Array.get(i));
   }
       

the problem is the divider is not showing between the radio buttons, how to solve it

You should add showDividers like this:

android:divider="@color/radiogroup_divider"
android:showDividers="middle"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM