0

I am working on a keyboard application in android, and I have a small problem when writing text on a button.

I am trying to do something like this:

enter image description here

I have one solution. My string.xml is:

<string name="multiplelines">q \n1\t|</string>

In my keyboard.xml:

<Button android:id="@+id/xQ" android:text="@string/multiplelines"/>

My output is like this:

enter image description here

So, my question is:

  1. How can I give different colors and text sizes to different text on the same button?
  2. Is this the right way to use css in android?
Esoteric Screen Name
  • 6,082
  • 4
  • 29
  • 38
Aniket
  • 2,204
  • 5
  • 34
  • 51
  • I don't know if it will work, but you might want to look at `SpannableString` http://developer.android.com/reference/android/text/SpannableString.html – David M Jun 06 '13 at 16:08
  • 2
    `button.setText(Html.fromHtml("q
    1|"));` This does the trick with the colors, and the second line characters are somewhat smaller.
    – Eri Jun 06 '13 at 16:45
  • @Eri your solution solved my problem, but i have one more issue related with use of button,As you see on first image, i need the alphabet('q') is in top left corner on button, number('1') in place of 'q' and '|' at his same place.I tried to use margin attribute in above syntax but it's not working... – Aniket Jun 11 '13 at 06:07
  • It seems like android buttons does not fully support all html attributes. However you might be able to do something like [this](http://stackoverflow.com/a/4867756/1302697). – Eri Jun 13 '13 at 12:50

0 Answers0