tags:

views:

1675

answers:

4

I need to show a large number of EditText controls on a screen, each of which will only allow entering 0-2 digits. The default EditText size is too wide for me to show enough EditText controls on a screen, but I have been unable to figure out how to make them narrower. I have tried the following attributes in XML: android:maxLength="2" android:layout_width="20dip" android:maxWidth="20px" android:ems="2" android:maxEms="2". So the question is: how can EditText be made smaller than default?

+2  A: 
Feet
That actually looks about as wide as the default to me. How does it look if you have just two characters in the EditText?
Heikki Toivonen
OK, I see what you mean now. With no width specified, the whole width of the text is used for the default up to the width of the screen.
Feet
Ah, got it. My problem was that I had the controls in a table, and changing just one made no change. Once I changed them ALL I saw the changes.
Heikki Toivonen
+1  A: 

Hey once you try this,it may work....... android:textAppearance="?android:attr/textAppearanceSmall"

jetti
A: 

In case you end up on this page to search how to achieve the same in Java code..

txtSample.setFilters(new InputFilter[]{new InputFilter.LengthFilter(2)});
Nikhil Patil
A: 

When in a table, as you describe, android:layout_gravity="left" will collapse the EditText to to the stated size of the EditText