I am trying to find a library or a simple trick to fix the width of each letter in an EditText so that the dashed lines on the background match exactly the number in the EditText. You can see the photo for the desired effect.
-
I think you should define a layout for each number which contains a textview for letter and a view for underline. set width and height as you wish. than add it to a horizontal linearlayout for each letter – Hakan Saglam Jan 24 '19 at 15:35
-
@HakanSaglam that's what I will do if I can't find a simpler solution. – emrah Jan 24 '19 at 15:48
-
1https://github.com/ChaosLeong/PinView this will help you – Erselan Khan Feb 05 '19 at 16:20
3 Answers
Using various widget i.e. Edittext in a row with the text style to underline will helps to get these type of design else i don't think there is any hard and fast rule or tricks.

- 143
- 9
There is no simple way of doing this, especially not when aligning to a given background, because many factors such as display size and density can change the relative positioning of the EditText. You could perhaps work around this limitation by drawing the white lines under each digit yourself, using a custom font or underlining and separating the digits with a space. See this question for a more detailed explanation on the limitations and possibile solutions concerning letter spacing.

- 564
- 3
- 11
I only know that, font monospace will be useful. Other fonts set different widths to each character.

- 86
- 6
-
This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/32597436) – Sweta Jain Sep 04 '22 at 17:02