Edit text in android - android

Hi am having one Edit Text which is used to get the information about the user.i have set the following properties to edit text
<EditText
android:id="#+id/profile_about"
android:layout_below="#id/AboutYou"
android:layout_centerInParent="true"
android:layout_marginLeft="8dip"
android:layout_marginBottom="10dip"
android:layout_marginRight="18dip"
android:gravity="top|left"
android:inputType="textCapWords"
android:textColor="#000000"
android:background="#drawable/edittext"
android:layout_width="300dip"
android:layout_height="100dip"
android:textSize="16sp"
/>
the problem is it scrolls horizontal only.not go the newline after entering certain characters.can anybody help me?

I replaced android:inputType="textCapWords" by android:inputType="textMultiLine|textCapWords", and it works.

Try using android:singleLine="false"

android:singleLine="false"
if this property is set then the charecters after a certain limit will go to next line automatically...
try this too
android:scrollHorizontally="false"

Related

Set AutocompleteTextView hint in a single line with Ellipsize end

I want to set the hint of my AutocompleteTextView in a single line with extra string to be truncated with dots(...) in the end.
I am using singleLine="true", maxLines="1", ellipsize="end".
But still the hint is shown in two lines. Although The text is set to single line. But I need the hint should also need to shown in single line.
The Preview in Android Studio shows the hint in single line. But when I run it on Device it shows in 2 lines.(S5, Nexus-5, Nexus-6, J7).
I also want the imeOption should be always search. i.e. imeOptions="actionSearch" Hence I can't change it to actionNext.
Below is my XML Code:
<RelativeLayout
android:id="#+id/liLaySearchMap"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:paddingLeft="10dp"
android:background="#color/cococo"
android:paddingRight="10dp">
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/five_dp"
android:background="#color/white"
android:padding="#dimen/two_dp"
android:scrollHorizontally="true"
android:drawablePadding="#dimen/two_dp"
android:singleLine="true"
android:lines="1"
android:maxLines="1"
android:ellipsize="end"
android:textSize="#dimen/twelve_sp"
android:drawableLeft="#drawable/ic_action_search"
android:inputType="text"
android:hint="A Very Long Hint Text Which Need To Be Tuncated At the End In Single Line"
android:id="#+id/edSearch"
android:imeOptions="actionSearch"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/tvCancel"
/>
<TextView
android:id="#+id/tvCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:layout_margin="#dimen/five_dp"
android:text="#string/cancel"
android:textSize="#dimen/twelve_sp"
android:textColor="#color/tw__composer_red"
android:padding="#dimen/five_dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"/>
</RelativeLayout>
Can Anyone Please en-curtain the issue I am facing. As I think I had used every possible solution but still the hint is not in single line.
these are screenshots on my Device and xml i tried is as follows
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="#color/white"
android:padding="2dp"
android:scrollHorizontally="true"
android:drawablePadding="2dp"
android:singleLine="true"
android:lines="1"
android:maxLines="1"
android:ellipsize="end"
android:textSize="16sp"
android:inputType="text"
android:drawableLeft="#mipmap/ic_launcher"
android:hint="A Very Long Hint Text Which Need To Be Tuncated At the End In Single Line"
android:id="#+id/edSearch"
android:imeOptions="actionSearch"/>
try Setting android:inputType="text" on the AutoCompleteTextView it worked for me
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
android:inputType="text"
android:ellipsize="end"
android:imeOptions="actionNext"
android:hint="this is to check if it's getting truncated and in single line or not"/>
Setting android:inputType="text" on the AutoCompleteTextView it worked for me, unlike android:ellipsize="end", the text did not stay with '...' on end, but it does meet expectations.
android:completionThreshold="1"

How can we specify line limit in multiline EditText with done action on keyboard in android?

I have Multiline EditText in my project. I want limit of line in my EditText. I specify all the property's like android:lines="3", android:maxLines="2", android:gravity="top|left" etc. in it but it is not restricted to 3 line. It is going beyond that.
My EditText code is :
<EditText
android:id="#+id/etForDesc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/edittext_back_profile"
android:hint="#string/desc"
android:imeOptions="actionDone"
android:paddingBottom="10dp"
android:paddingLeft="13dp"
android:lines="3"
android:maxLines="2"
android:gravity="top|left"
android:paddingTop="10dp"
android:textStyle="normal" />
Please help me.
Thank you.

how to fix the size of multiline edit text

I want to make a multi line edit text but the problem is that whenever i enter new line height of edit text increases. how to fix its height. My code is
<EditText
android:id="#+id/editAdditionalInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/editPhoneCutomerDetails"
android:layout_alignParentBottom="true"
android:layout_marginBottom="60dp"
android:layout_below="#+id/editPhoneCutomerDetails"
android:layout_marginTop="10dp"
android:background="#drawable/message_additional_box1x"
android:ems="10"
android:padding="10dp"
android:gravity="top">
<requestFocus />
</EditText>
To fix the size of editText you can use
android:singleLine="true"
but it can limit your editText line to 1 .
if you want more lines in editText then use the following property.
Use android:lines="3" .
Use android:lines="2" for fixing multilines and for fixing single line use android:singleLine="true"
for example use like this as shown for multilines
<EditText
android:id="#+id/.."
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:drawable/editbox_background_normal"
android:ems="10"
android:hint="Name"
android:maxLength="20"
android:lines="2"// fix the multiline limit
android:textColor="#000000" />
for example use like this as shown for single line
<EditText
android:id="#+id/.."
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:drawable/editbox_background_normal"
android:ems="10"
android:hint="Name"
android:maxLength="20"
android:singleLine="true"// fix the single line limit
android:textColor="#000000" />
try this;
android:inputType="textMultiLine"
<EditText
android:inputType="textMultiLine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
As singleline is now deprecated use inputType:multiline and set the number of lines you want with lines tag
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:lines="4"/>
I had a similar requirement but ended up not changing the size of the box. i.e it grows as text is typed into it but stops short of blocking the other widgets in view. I read this post during my quest and had found a solution. Decided to post it back here. Restricting size to a value may possibly have different effects on different screens. So I think it is better to let it be.
The thing is to put the edit text inside a linearlayout with the rest of the widgets. The code and snapshot are here
Multi line edit box with ok cancel buttons

How to add hint into EditText with inputType="numberDecimal"?

I have an EditText like below:
<EditText
android:id="#+id/et_sum"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:background="#android:drawable/editbox_background"
android:gravity="center_horizontal"
android:inputType="numberDecimal"
android:hint="Enter sum" />
But the hint is not displayed. Is it possible to display the EditText hint with inputType="numberDecimal" or not?
you can use
android:ellipsize="start"
to make the hint displayed with an inputtype and gravity
It appears to be a problem with using android:gravity="center_horizontal". Try removing that line as it made the hint appear for me.
Here is one of my EditText tags to compare with:
<EditText
android:id="#+id/txtNumbText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="18sp"
android:inputType="numberDecimal"
android:singleLine="true"
android:hint="Number Hint Text">
</EditText>
Hi we can not use Gravity attribute and inputtype="number" attribute at a time so better to neglect gravity attribute.
if u want set hint in middle of edit text use like this : android:hint=" hint "
give space in hint text
<EditText android:id="#+id/xEt" android:layout_width="170dip"
android:layout_height="wrap_content"
android:layout_marginRight="20dip"
android:inputType="number"
android:hint=" numbers only "
android:layout_alignParentRight="true" />

EditText with long default text on a single line

I have an EditText that I am trying to set with a very long, unbreaking text value (a URL), but even with the following XML declaration, the text is breaking to a second line.
<EditText
android:id="#+id/address"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:maxLines="1"
android:hint="Enter URL"
android:text="http://www.example.com/news/2010-07-15/this-is-the-story-title-here.html">
</EditText>
I've tried the solutions here (adding android:ellipsize="end"), but it made no difference. Reducing the text in length to something no more than the length of the EditText worked... but this is realistic for a URL EditText.
Any suggestions?
Thanks,
Paul
Set
android:scrollHorizontally="true"
Have you tried adding android:singleLine="true" to the mix
<EditText
android:id="#+id/address"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:singleLine="true"
android:maxLines="1"
android:hint="Enter URL"
android:text="http://www.example.com/news/2010-07-15/this-is-the-story-title-here.html">
</EditText>
Use value for the attribute inputType other than textMultiLine. The attribute singleLine is deprecated.

Categories

Resources