Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make blink effect on textview on click?

Hi I am new to android development. I want to create onclick effects to textview. When I click on the textview it will blink or something effects make. I tried it with change color, but it's not working. How can I make blink effect on textview onclick ?? please help me with example code. thanks in advance :)

like image 534
Maxwell Avatar asked Apr 23 '14 10:04

Maxwell


People also ask

How do you animate TextView?

To start the animation we need to call the startAnimation() function on the UI element as shown in the snippet below: sampleTextView. startAnimation(animation); Here we perform the animation on a textview component by passing the type of Animation as the parameter.

Can I make a TextView clickable?

Just like Buttons and ImageViews we can add onClickListeners to TextViews by simply adding the attribute android:onClick="myMethod" to your TextView XML tag. The other way, TextView tv = (TextView) this.

How do I make a TextView look like a link?

This is the shortest solution: final CharSequence text = tv. getText(); final SpannableString spannableString = new SpannableString( text ); spannableString. setSpan(new URLSpan(""), 0, spannableString.


2 Answers

The easiest way is to set this background in the TextView:

 android:background="?attr/selectableItemBackground"

And if you want to set a different color for the background, set that attr as foreground instead of background.

like image 174
kikettas Avatar answered Oct 13 '22 20:10

kikettas


try this. it worked for me.

        android:clickable="true"
        android:focusable="true"
        android:background="?android:attr/selectableItemBackground"
like image 14
Juboraj Sarker Avatar answered Oct 13 '22 18:10

Juboraj Sarker