I have a text in
textview
which i need it to be blinking please help me with it.
I tried this 1: How to make the textview blinking.
But here the TextView is blinking. I need only the text that is,"Text1" to blink.
I have a text in
textview
which i need it to be blinking please help me with it.
I tried this 1: How to make the textview blinking.
But here the TextView is blinking. I need only the text that is,"Text1" to blink.
Try this you can to use setText()
to make blink effect in TextView
Try below code
<TextView
android:id="@+id/usage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimaryDark"
android:gravity="center"
android:textColor="#d92804" />
Java Code;
TextView textView;
textView = (TextView) findViewById(R.id.textView);
testBlink();
private void testBlink() {
final Handler handler = new Handler();
new Thread(new Runnable() {
@Override
public void run() {
int timeToBlink = 1000;
try {
Thread.sleep(timeToBlink);
} catch (Exception e) {
}
handler.post(new Runnable() {
@Override
public void run() {
if (textView.getText().toString().equals("")) {
textView.setText("Nilesh");
} else {
textView.setText("");
}
testBlink();
}
});
}
}).start();
}