0

Is it possible in Android to add effects to TextView.

Lets say I have a TextView where I add points and the effect would be that when a point is added the TextView would grow larger for a second or do something that the user would notice that he has achieved something.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Richard
  • 1,087
  • 18
  • 52

2 Answers2

0

Yes, it is possible. If you have a button that adds points to the textview then, set a onclick function for that button (or any other layout element) For animations, check links here and here

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Kunj Mehta
  • 411
  • 4
  • 11
0

create a layout with a TextView that will receive the blink effect and a Button to start the blink effect-

activity_main.xml
------------------------------------------------------------------------------
 <TextView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text=" Blink Effect with SSaurel "
  android:textSize="22sp"
  android:layout_centerInParent="true"
  android:id="@+id/txt"
 />

 <Button
  android:text="Blink Effect !"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:id="@+id/btn"
  android:layout_below="@id/txt"
  android:layout_marginTop="50dp"
  android:layout_centerHorizontal="true"/


MainActivity
--------------------------------------------------------------------------
@Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  txt = (TextView) findViewById(R.id.txt);
  blinkBtn = (Button) findViewById(R.id.btn);
  blinkBtn.setOnClickListener(new View.OnClickListener() {
   @Override
   public void onClick(View v) {
    manageEffect();
   }
  });
 }

 private void manageEffect() {
  ObjectAnimator anim = ObjectAnimator.ofInt(txt, "backgroundColor", Color.WHITE, Color.RED,
   Color.WHITE);
  anim.setDuration(1500);
  anim.setEvaluator(new ArgbEvaluator());
  anim.setRepeatMode(Animation.REVERSE);
  anim.setRepeatCount(Animation.INFINITE);
  anim.start();
 }
Vishal Sharma
  • 1,051
  • 2
  • 8
  • 15