android - How to make text on button appear and disappear continualy -
i have button want text appear 1 second disappear 1 second, loop 6 seconds, here tried:
for(int = 0 ; < 6 ; i++) { button.settextsize(18); try { thread.sleep(1000); } catch (interruptedexception e) { e.printstacktrace(); } button.settextsize(0); try { thread.sleep(1000); } catch (interruptedexception e) { e.printstacktrace(); } }
first appear button's text size became 36 instead of 18,
second is not act expected, never show text,
note: text size start 0.
how can achieve this?
okey suggested want blink textview
, here can do.
create on folder under res
called "anim", create 1 xml file under
blink.xml , copy code in it.
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <alpha android:fromalpha="0.0" android:toalpha="1.0" android:duration="1000" android:repeatmode="reverse" android:repeatcount="infinite" /> </set>
now in java class apply animation textview
animation anim = animationutils.loadanimation(getactivity(), r.anim.blink); yourtextview.startanimation(anim);
done.
Comments
Post a Comment