Change color of a radio button

前端 未结 11 1867
死守一世寂寞
死守一世寂寞 2020-12-10 02:11

I am developing an quiz based app. There will be 1 question and 4 option(radio buttons). If user select any wrong answer then I want to turn that radio button color to Red.

11条回答
  •  爱一瞬间的悲伤
    2020-12-10 02:50

    Just came to show something that really help me with this:

    Everyone talks about how to use the tint and how to use the colorAccent, but, this wont work on phones with API less than 21.

    So, the real fix on this or at least what helped me was to use android.support.v7.widget.AppCompatRadioButton instead of RadioButton

    With this on your layout, you can use: app:buttonTint="@color/yourColor"

    without getting warnings or problems about the compat of the view.

    And, don't you forget about adding:

    xmlns:app="http://schemas.android.com/apk/res-auto"

    to your layout parent or to your widget.

    Edit:

    @aselims mention on a comment that there's not buttonTintin the app namespace.

    So... here's my current style for this solution:

    
    

提交回复
热议问题