Android: Height of EditText widget - android

I need to make an EditText smaller in height than the default wrap_content height.
Reducing the layout height property doesn't work. Reducing the text size property doesn't work. Reducing the padding doesn't work. All these attempts have produced horrible visual effects.
Does anyone please know how to do this successfully ?

It's not possible unless recreating the ui pictures.

Related

Limited WRAP_CONTENT for edittext

I want that when my edittext is empty it's height is 40px, i.e., it takes space of only one line. And when text is typed the height increases. It should function more like the WRAP_CONTENT on its height, but I want that once it reaches the height of (5*40px) or 200px, i.e., space of 5 lines. It doesn't increases anymore. It acts as if it's height is fixed 200px. How can I access this type of height feature.
Please try to help by providing Programmatic reference rather than XML reference. Thanks in advance...
You should check this question out. It has exactly what you need. Next time while asking a question, please do a little bit research.
Set limitation for EditText height and Maximum lines
Also, there's a tag called android:maxLines="int"or editText.setMaxLines(int numOfLines) method if you want that to set how much the EditText will stretch. It'll do exactly what you need to do.

Is it possible for content (size) to match parent?

If I have a text in a button that has match_parent, is it possible to make the textSize as big as possible without cropping the text? Preferably in XML and with a maximum setting so it doesn't become too big. In other words I'd like it to make it just fit if it would split a long word, otherwise stick to the preset size.
This way, but it does not look clearly in my opinion you should to try to change your design to avoid this requirement

whats better, giving hard coded height or using weight parameter to set View parameters..?

I usually give fixed height in order to avoid views getting overlapped on orientation change, But is giving weight is better than this..?, share it if there are better ways to give LayoutParameter.
Thank you.
It completely depends on situations, like when my view should cover a part of width and height available on screen, then I would opt for weight and when it should be fixed in dimensions irrespective of width, height then use fixed layout co-ordinates.

Layout designing on Android Board

I'm designing a game board in Android. I need to put a button and an image view in between Admob and the board. I am able to do so, but it is having compatibility problem because I have hard coded the values like height and width. I want to know how I can do it without hard coded values. Please help me.
Dont use hard code height and width.
1. You must use dip unit instead of pixels.
2. set layout_width and layout_height as either WRAP_CONTENT or FILL_PARENT
3. Dont use AbsoluteLayout
4. Use layout_weight,layout_marginleft,layout_marginright....etc properties.

Problem with borders when resizing the height of EditText

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.
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.
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!

Categories

Resources