I have a TextView which I dynamically add clickable links via Linkify (with a custom TransformFilter). This all works great. What I would like to do now is change the background color of the link when its clicked. In CSS it would be done via the :active
pseudo-selector.
I would think I can specify this in styles.xml but I dont know what the parameter name is.
Inside the function use setBackgroundResource(R. color. button_color) function, this will set the background with color button_color.
Use the colors in your themeOpen themes. xml (app > res > values > themes > themes. xml). Change colorPrimary to the primary color you selected, @color/green .
You can create a theme the same way you create styles. The difference is how you apply it: instead of applying a style with the style attribute on a view, you apply a theme with the android:theme attribute on either the <application> tag or an <activity> tag in the AndroidManifest. xml file.
To set Android Button background color, we can assign android:backgroundTint XML attribute for Button in layout file with the required Color Value. To programmatically set or change Android Button background color, we may call pass the method Button.
Just had this problem myself and the solution for me (but I didn't use Linkify) was the android:textColorHighlight
attribute. I used android:linksClickable="true"
instead of Linkify
though. That won't probably make any difference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With