2

Im a fresher to android..and now i need to animate a text sequence given below and after one cycle the text color should change from red to white gradually.

A

An

And

Andr

Andro

Androi

Android

Dinsha
  • 41
  • 1
  • 4

1 Answers1

2

Since you're using a TextView, you can use a loop to gradually change the color and append the text dynamically e.g.

char[] letters = "Android".toCharArray();
for (int i = 0; i < letters.length; i++) {
  Thread.sleep(1000);
  view.append(letters[i]);
  view.setTextColor(color);
}

A helpful link on creating the gradient is here Generating gradients programmatically? and to use that to create a color, you can use

view.setTextColor(Color.rgb(r, g, b));
Community
  • 1
  • 1
Lexicographical
  • 501
  • 4
  • 16
  • Thank you....I understood the code but can I get something other than view....because Im not having much idea using view. – Dinsha May 30 '16 at 05:34
  • The view can be your TextView. – Lexicographical May 30 '16 at 06:09
  • @Dinsha view in this case your text view. `TextView view = (TextView) findViewById(R.id.myTextView);` – KISHORE_ZE May 30 '16 at 16:26
  • I have done using two TextViews overlapping.....in TextView1 I have assigned the text and color in xml file...and in TextView2 I need to assign a text and color programmatically with the above sequence model..but this cncept doesnt work as my idea. – Dinsha May 31 '16 at 05:28