I can't really explain this, so I'll use an image:
OK, so as you can see, the actual EditText View is slightly taller than the actual white (editable area). How is this? I've removed all padding and margin that View has and still it looks bad.
Also I have another 2 problems with this EditText view when deploying it on the device:
It automatically captures focus (how can I disable this?)
When focusing it, there is an orange border, but the actual editable area is wider than the orange borders (see screenshot 2):
Here is the background of the pre Holo EditText:
And here is the background of the pre Holo EditText when its selected:
As you can see, those 9Patches already have paddings in them. So you the height of the EditText won't be the same as the height of the actual editable area. I would recommend you to set the height to wrap_content.
Related
There will be a blank between the content text and the border of the TextView, even if the padding is 0. And if the height of the TextView and the content text is set to a same value, the text will not be completely displayed.
So, what's the height of blank between the content text and the border of the TextView?
The extra spacing is built into the font. It's there to accomodate special characters that are very tall.
Similar question: How to remove the top and bottom space on textview of Android
Adding android:includeFontPadding="false" may help a little, but I've found it doesn't do much.
I set the button's height via XML. Suppose it to be X
<Button
android:layout_height="wrap_contnet"
android:textSize = " <X> dp"
....
....
/>
If I set X to greater than 15 dp, the button's height grows to fit the text. But when I set it to something lower like 2dp, the button's height doesn't change and I can see a thick border around it as shown below:-
As shown above, text size is so small but still height doesn't decrease!
How can I force it to be of appropriate height?
Thanx in advance!
Font size does not depend on button height. If you set it too small to fit the text, you will get the result you observe
EDIT
wrap_content would usually do the trick, however Button class sets some layout parameters like margin, background so it takes more space. You may get rid of Button and use i.e. TextView class, styled by hand to match your design. onClickListener will work perfectly fine with it and you will get result you want and full control over your button
EDIT 2
As this is bit related - there's AutoFitTextView widget on Github that deals with automatic text size scalling: https://github.com/grantland/android-autofittextview
Just Set android:minHeight="xxdp"
What do I have to use to create a text input like evernote's?
It's look like they are using two edittext to create this, but even if I can have the same style for the upper part (whith one edittext), I don't know how to do the bottom part: it's look like the edittext is divided in two part, and the bottom part is taking the full screen.
Do I have to create some custom view?
It is easy. There are three main elements.
EditText with specified height (18sp for example) and width match_parent,
no padding/margin, 1dp height, match_parent width View element,
EditText with no padding/margin, width match_parent, specified height (36sp for example)
They also use hint option to display text in EditText, and View background color same as hint text color.
I was wondering about what is wrong with my layout.
Here is a screenshot.
Problem being that the text is being cut off in edit text boxes.
I suppose there is something wrong with the text's XY co-ordinates at the time of typing in those edit text boxes; the cursor blinks fine to me.
Here is the pastebin of my XML layout (not putting it here because its quite lengthy).
Any advice will be appreciated. Thanks
The text size of the text inside edittext is large for hardcoded 30dp height of edittext. You can either set edittext height to wrapcontent or reduce the textsize of edittext (10-14sp)so that it fits inside.
It is advised by android to set minimum height of clickable area to at least 48dp.
http://developer.android.com/design/style/metrics-grids.html
Android, Button view. The Button size is 38x38dp, text size is 20dp (just one + character worth of text). Gravity is set to center|center_vertically.
The text is NOT centered vertically. According to Android's internal accounting, the text is too large for the specified button size, so the text is placed with its top aligned with the top padding, and its bottom cut off. That's not what I want; I want the text to be cut evenly on the top and on the bottom. In other words, vertically centered. The plus character, since it takes less than a full-sized character cell, won't suffer from that.
It's Gravity that I set, not Layout gravity. I know the difference.
Any ideas how to make vertical centering work in such conditions, short of overriding draw()?
Try adding android:includeFontPadding="false" to the Button view.
Some have suggested adding android:baselineAligned="false" to the container for similar problems but it didn't do anything for me.