You can use a simple AlphaAnimation object for AlphaAnimation . Set the repeat mode to setRepeatMode(Animation.REVERSE) to change alpha from 0.5 to 1.0 and setRepeatCount(count) to repeat several times.
xml animation sample:
<alpha xmlns:android="http://schemas.android.com/apk/res/android" android:fromAlpha="1.0" android:toAlpha="0.5" android:duration="1000" />
code to download xml:
Animation a = AnimationUtils.loadAnimation(this, R.anim.alpha); a.reset(); a.setRepeatMode(Animation.REVERSE); a.setRepeatCount(5);
The code is just a sample. Hope this works.
source share