Reputation: 11
I'm developing an Android app targeting Android 2.3 (API9).
I want to resize the height of a simple EditText
but when I set android:layout_height="10pt"
the border of the EditText
becomes dislocated.
The problem is shown here
I tried layout_height, height, textsize.. pt, px, sp... but the same problem.
I haven't tried the application on real device yet.
Upvotes: 1
Views: 1270
Reputation: 9551
I have been having the same sort of problem (and it's a real pain). With some experimentation I have found that if you use "dp" and apply this rule of thumb, it should work for EditText fields.
textSize x 3= layout_height
I say rule of thumb because the minimum height before the field "breaks" again is about 29dp. So, for example if you have textSize="10dp", then layout_height="30dp", or textSize="12dp", then layout_height="36dp". You can have smaller textSizes, but it becomes illegible lower than 9dp. I found this works well in relative_layouts with default fonts. Good luck!
Upvotes: 0
Reputation: 46844
What layout contains the EdiText
? You should never use exact pixel sizes when configuring items in Android, since your layout needs to work properly at many different screen sizes and densities. (See supporting multiple screens for details).
If you really want a specific size, us dp for density independent pixels. It should work to set the layout_height="10dp"
However, that won't increase the size of the text within the EditText. You need to use textSize
for that. You are probably better off setting textSize
and setting the layout_height="wrap_content"
.
See this similar question about the extra line. It looks like setting a background color might fix that.
Upvotes: 1