I have a strange problem. Whatever in Edittext , all letters are autocapitalize. I don't want that. I want text to appear same as user types which is lower and uppercase both.
Here is my code
<EditText
android:layout_width="match_parent"
android:textAppearance="? android:attr/textAppearanceSmall"
android:layout_height="150dp"
android:cursorVisible="true"
android:layout_marginBottom="15dp"
android:hint="Feedback"
android:background="#drawable/edit_text"
android:textCursorDrawable="#null"
android:gravity="top"
android:inputType="textMultiLine"
android:padding="8dp"
android:id="#+id/feedback_input" />
Make android:textAllCaps="false" in your edit text.
Related
enter image description hereI am using 2 type edit text in my login page. In Arabic EditText gravity is END.But hint in EditText getting left align Why?. When i give inputType="textPassword" no issues. Issues in android:inputType="textEmailAddress"
EditText code given below
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/userName"
android:inputType="textEmailAddress"
android:gravity="end"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/password"
android:inputType="textPassword"
android:gravity="end" />
Try removing :
android:gravity="end"
In the first EditText. It should automatically make the text RTL if you already placed arabic values-ar in values folder.
Don't forget to add:
android:supportsRtl="true"
In AndroidManifest.xml also.
Update;
Didn’t get you at first but, add these:
android:layoutDirection="rtl"
android:textDirection="rtl"
This will make the layout & text direction rtl and should help for the purpose.
Try with this
<EditText
android:id="#+id/username"
style="#style/Widget.EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="viewStart"
android:hint="#string/username"
android:layoutDirection="locale"
android:padding="10dip"
android:textDirection="locale" />
<EditText
android:id="#+id/password"
style="#style/Widget.EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="viewStart"
android:hint="#string/password"
android:layoutDirection="locale"
android:padding="10dip"
android:textDirection="locale" />
Can someone point me on how to limit the edittext as one line only?
screenshot:
my xml:
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Full Name"
android:id="#+id/textView_data2"
android:textSize="20sp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:maxLines="1"
android:gravity="fill_vertical" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Full Name"
android:scrollHorizontally="false"
android:id="#+id/textView_data2"
android:textSize="20sp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:maxLines="1"
android:inputType="textPersonName"
android:gravity="fill_vertical" />
Just add into your XML-File android:maxLines="1"
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Full Name"
android:id="#+id/textView_data2"
android:textSize="20sp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:inputType="text"
android:imeOption="actionNext"
android:gravity="fill_vertical" />
android:inputType="text"
android:imeOption="actionNext"
these two lines are the catch. you better use actionDon in imeOption
i.e.,
android:imeOption="actionDone"
use this and you are all good :)
P.S. there are multiple types of imeOption provided by android. We usually use these imeOptions for our softKeyboardInput where we need to change enter button of our keypad to anything else.
e.g., actionDone : DOne button
actionNext :Go to next editBox and etc,
These imeOption only works with inputType="text|number|..i.e. you need to specify a input type for using imeOption.
Hope it will help you :)
I would like for my app to be able to display different hints in the edittext at different times, so i have to set the hint pro-grammatically at each times as below.
editText.setHint("Hint 1");
But the problem is when i starts typing the hint starts disappearing.I want to show this hint every time.If i set the hint in xml it will not disappear while typing, but how to do this in my case.
Either you should consider to change to TextInputLayout(Strongly recommended this. Here is an example too.)
or
make relative layout with EditText for input and TextView for hint inside.Change the textview according to your needs.
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Some text"
android:layout_alignParentLeft="true"
android:id="#+id/editText1"
android:layout_gravity="center"
/>
<TextView
android:id="#+id/text_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="yourHint"
android:textSize="14sp"
android:layout_marginRight="10dp"
android:textColor="#color/customColor"
/>
</RelativeLayout>
what you are expecting is not possible,since we have to how what user is writing on editext.
Now a days https://github.com/hardik-trivedi/FloatingLabel
this type of hints are more popular,you can try above link.
TextInputLayout give powerful material features to EditText. Main feature is floating hint. See doc here https://developer.android.com/reference/android/support/design/widget/TextInputLayout.html
You can't display while typing text in edit text hint in android have default functionality
<android.support.design.widget.TextInputLayout
android:theme="#style/TextLabel"
android:id="#+id/input_layout_username"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/username_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#null"
android:hint="Email Address"
android:inputType="textEmailAddress"
android:translationY="10dp"
android:textColor="#color/white"
android:textColorHint="#color/white"
android:textSize="#dimen/font_13"/>
</android.support.design.widget.TextInputLayout>
Here android provide default functionality while typing text in edit text the hint above edit text, You can also set Hint via programmatically
EditText. setHint ("Hint 1");
the best way to do this is to use TextInputLayout.
https://www.bignerdranch.com/blog/becoming-material-with-android-design-support-library/
<!--EMAIL-->
<android.support.design.widget.TextInputLayout
android:id="#+id/email_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/TextLabel">
<EditText
android:id="#+id/etUserName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/login_screen_email_hint"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"
android:maxLines="1"
android:nextFocusDown="#+id/etPassword"
android:singleLine="true"
android:textColor="#android:color/white"
android:textColorHighlight="#android:color/white"
android:textColorHint="#android:color/white" />
</android.support.design.widget.TextInputLayout>
And dont forget adding this line to your gradle file
compile 'com.android.support:design:23.4.0'
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"
I had an issue with setting hint in Arabic language. Please refer Alternating edit text hint not visible for Arabic language
for details. The issue was with the use of inputType in the xml. I have removed it and now a normal keypad appears onclick of the edittext field. But I want the user to enter numbers only and I want numerical keypad to appear. How to do it?
In short, the use of inputType will not display the Arabic content and if it is not used then I am getting alphabetical keypad.
Please help, thanks in advance
hope you can use this property android:numeric="integer" and please remove singleline property if you are using it.
<EditText
android:id="#+id/et_account_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:color/transparent"
android:cursorVisible="true"
android:gravity="right"
android:hint="#string/hint_account_no"
android:imeOptions="actionNext"
android:numeric="integer"
android:maxLength="12"
android:textColor="#android:color/black"
android:textSize="20sp"
android:padding="#dimen/edittext_padding">
</EditText>
Use android:inputType="number" or android:inputType="phone" it should give you numeric keypad on click of edit text:
Following is the snippet from my xml, this should help:
<EditText
android:layout_gravity="start"
android:textAlignment="viewStart"
android:hint="my hint"
android:inputType="phone"
android:id="#+id/Nummm"
android:paddingStart="8dp"
android:paddingLeft="8dp"
android:textDirection="rtl"
android:gravity="center_vertical"
android:layout_width="match_parent"
android:background="#android:color/transparent"
android:textColorHint="#767676"
android:backgroundTint="#android:color/transparent"
android:layout_height="fill_parent"
tools:ignore="RtlCompat" />