I want to give extra space to input texts in my edit text.
here is what I have now :
but I want to achieve this :
which property of edittext will do this (in xml) ?
or I have to do this in another way ?
Thanks in advance !
android:paddingLeft is the property you need. You can use it as android:paddingLeft="8dp"
Checkout this answer here: https://stackoverflow.com/a/4619943/1739882
Add this attribute:
android:paddingLeft="10dp"
padding usually used to give an alignment to the text inside the EditText or even Buttons
please inform me if this is what you are looking for
Related
What I would like to achieve is an effect that looks like this with a TextView:
Basically having a background, but keeping the space between the lines. The only solution I came up with was using one TextView for each line of text, but I would prefer a cleaner one using only one multiline TextView.
Any ideas?
Use spanned text for each line. Read the Spannable API.
please refer to this answer here as it describes how to implement spacing between multiple lines in a TextView , using the following properties :
android:lineSpacingMultiplier
android:lineSpacingExtra
Hope that Helps .
Regards
What you can do is use mark tag in html to textview.
myTextView.setText(Html.fromHtml("<mark>heading highlighted</mark>"));
I'm very new to android and I want to reduce the size of EditText field in my layout.
For example if the user only need to enter 3 digits to the text field, then the size of the EditText should be small enough not the one provided by default.
Is that possible to do so?
Thanks in advance.
Try like this..
android:layout_width="wrap_content"
or
android:layout_width="20dp" //size your choice
In your Layout file set the attribute to that text field width as
android:layout_width="wrap_content"..This will take width as the text content entered into the field
You can use
android:layout_margin="size you want"
use can also use
android:layout_margin_left="size you want"
instead of "left" you can also right, top, bottom.
If you open an app like gmail, and you compose a new email in the To and Subject lines, it says To and Subject in the respective EditText's. How do you add a title like that to an EditText? Are those custom views? Or is it possible to do that with the default widget?
Thanks.
It is called a hint.
Set your hint programatically or use it as xml attribute.
I think the attribute hint is what you are looking for.
Here is some sample code:
<EditText android:hint="Write Caption" />
hi all i have a lil problem in android edit text
actually i made an app in which i m using two text fields for user name and password and set EditText size manually like in 200dip format. now when there is no text in the Edit Text it is in perfect size like in the image below but when we start typing text and the text exceeds the size of editText Field then it Expand downwards like in second image below.
What I want is that when text exceeds the size of EditText, it should not Change its size. please help
android:singleLine="true" should work.
add this property for EditText and check...
android:singleLine="true"
You have to do your ExitText to be single line. You can use android:singleLine but it is deprecated and it's replaced by android:inputType. Use android:inputType=text for single line and android:inputType=textMultiline for multiline
android:maxLines="1"
Another property...
I am trying to create an EditText which toggles its state between read only and write mode.
My XML is as below:
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/textArea"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:lines="4"
android:inputType="textMultiLine">
</EditText>
In my code i do the following :
textArea = (EditText) convertView.findViewById(com.pravaa.mobile.R.id.textArea);
//isEditable decides if the EditText is editable or not
if(!isEditable){
textArea.setInputType(InputType.TYPE_NULL);
}
//the view is added to a linear layout.
addView(textArea);
My issue is that the text does not get wrapped. Am i missing out on something? Kindly help me with this. I have also attached an image of my output.
The text set in the view is "12345678901234567 90123456789012345678901234567890 Nationwide Campaign New"
I was able to solve this issue by removing
android:inputType="textMultiLine"
To achieve the non-editable feature I used
setFocusable(false);
I guess that by calling this ...
textArea.setInputType(InputType.TYPE_NULL);
you override the flag InputType.TYPE_TEXT_FLAG_MULTI_LINE. Try calling this instead...
textArea.setInputType(InputType.TYPE_NULL|InputType.TYPE_TEXT_FLAG_MULTI_LINE);
This line will make the text multi-line and will wrap the text
textArea.setInputType(InputType.TYPE_CLASS_TEXT|InputType.TYPE_TEXT_FLAG_MULTI_LINE);
You'd probably also want to call setLines(n) to set the height of the textArea.
Try to replace:
editText.setInputType(InputType.TYPE_NULL);
with:
editText.setRawInputType(InputType.TYPE_NULL);
I would say that by using textArea.setInputType(InputType.TYPE_NULL); you remove the textMultiLine from your xml.
Just set textMultiLine isn't enough. Try this:
textArea.setHorizontallyScrolling(false);
textArea.setEllipsize(null);
textArea.setInputType(InputType.TYPE_NULL|InputType.TYPE_TEXT_FLAG_MULTI_LINE);
What me helped was:
edtText.setInputType(InputType.TYPE_NULL);
edtText.setSingleLine(false);
It seems that the setSingleline Attribute in the XML file is ignored.