1

I have a question about textviews in android.

What I want to do is have a row of text (probably will be in a textview) but it will be a row of letters for a learning game.

So level one would say "AAAAA" for example, but I want each letter to be a different colour, like blue, red, red, blue, black.

But I want to reuse the code, so in level 2, they would be different colours. How would i go about changing the colours of these letters the way I want? I have about 30 levels, so it would be impractical to have a different layout for each one with the different text views.

I was thinking something, that it would be written something like this A[blue]A[red]A[black] you know, the colour I want it to be in the square brackets beside the letter. Thanks!

EDIT: maybe defining the colours of the letters, then passing that onto a string, which would then get applied to a textview?

cnfw
  • 770
  • 2
  • 11
  • 28
  • So far the only thing I've got working is creating a different textview for each letter, and setting its colour. but this is impractical as i have to then make a new layout for each level as the number of letters i'm showing is different each time. Sometimes there may even be words between the letters, like AAA Play AA, etc – cnfw Jun 04 '14 at 11:58
  • So its been marked as a duplicate, and the answer there will create much more work, but I guess it'll have to do – cnfw Jun 04 '14 at 12:03
  • you can check this http://stackoverflow.com/questions/6094315/single-textview-with-two-different-colored-text/24039182#24039182 – NaserShaikh Jun 04 '14 at 13:46

0 Answers0