简体   繁体   中英

RadioButton in ListView ripple effect

I have problem with RadioButton ripple effect. I want get this: I have ripple in full background of list item

but I have this: I have ripple only around mark

How can I implement this?

Apply click listener on itemView and in that listener check radio button as true or false. Change the backgroundTint to required color of radio button.

Ripple effect is available for API-level 21+ you can apply it to Radio buttons with android:background="?android:attr/selectableItemBackground" for each individual button

<RadioGroup
    android:id="@+id/radiogroup"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <RadioButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="?android:attr/selectableItemBackground"
        android:text="Option number one" />

    <RadioButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="?android:attr/selectableItemBackground"
        android:text="Option number two" />
</RadioGroup>

Use CheckedTextView in ListView with SINGLE_CHOICE_MODE parameter.

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