0

I am using an EditText to display text received from a serial port which is updated 10 times a second, it works fine but one of the lines of text has a character that alternates beyween a digit and a dash (-). Becuase the dash is narrower than the digit the rest of the line of text after this character jumps right-left as the digit and dash alternate.

How can I prevent this so either the digit or dash could be displayed without the rest of the line jumping?

TIA

Andrew Smith
  • 117
  • 9

2 Answers2

1

You should use monospace font. You can either change it with the visual designer or by code:

EditText1.Typeface = Typeface.MONOSPACE

Visual designer:

Visual designer:

Erel
  • 1,802
  • 2
  • 15
  • 58
  • Thanks, easy when you know how. Is it possible to have different font sizes on different lines with the same EditText? – Andrew Smith Oct 02 '11 at 14:25
  • You can probably do it with the RichString library: [link](http://www.basic4ppc.com/android/help/richstring.html) Note that you should accept the answer to mark it as the correct answer. – Erel Oct 02 '11 at 14:29
0

You then should probably use monospace font:

<EditText android:typeface="monospace" [rest of attributes] />
Aleks G
  • 56,435
  • 29
  • 168
  • 265