I have a simple EditText inside my scrollview.
All the other elements are working just fine, however i won't get the usual EditText behaviour on click (Keyboard doesn't appear, I can't write).
Here's my xml for the field.
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/enterWishprice"
android:background="#drawable/edit_back"
android:focusable="true"
android:focusableInTouchMode="true"
android:text="0 F€"
android:gravity="center_vertical|center_horizontal"
android:textSize="26dp"
android:inputType="number"
android:layout_margin="10dp" />
As you can see I already tried setting focusable/inTouchMode.
I also tried setting a click listener on the field to manually open the keyboard which works just fine. However I still can't type anything into the field.
After that i tried using requestFocus in the clicklistener without any result.
Furthermore I tried clearFocus on the EditText as well as the surrounding ScrollView - also not working.
Hopefully you can give me a hint cause I'm out of ideas..
Thanks in advance!
The attribute Enabled must be set to true.
<EditText
android:id="#+id/room_message"
android:layout_width="164dp"
android:layout_height="46dp"
android:clickable="true"
android:ems="10"
android:enabled="true"
android:focusableInTouchMode="true"
android:hint="#string/prompt_message"
android:inputType="textPersonName"
android:textColor="#FFFFFF"
android:textSize="18sp"
android:textStyle="italic"
/>
But i have got another problem where the EditText won't lose focus....
try like this
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/enterWishprice"
android:background="#drawable/edit_back"
android:focusableInTouchMode="true"
android:text="0 F€"
android:gravity="center_vertical|center_horizontal"
android:textSize="26dp"
android:inputType="number"
android:layout_margin="10dp">
<requestFocus />
</EditText>
Related
I'm facing an issue regarding EditText.
EditText is not working in couple of android devices when inputType:Text / TextMultiline/ TextPersonName.
but when you use inputType:Number
It works in all devices
what is the issue?
<EditText
android:id="#+id/quantity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Quantity 1Kg Meat etc"
android:focusableInTouchMode="true"
android:textIsSelectable="true"
android:clickable="true"
android:inputType="text"
android:textSize="14sp"
android:textColor="#android:color/black"
android:textColorHint="#android:color/black"
android:layout_below="#+id/line1"
android:layout_alignParentStart="true" />
Firstly it didn't show the keyboard
then i use this
android:windowSoftInputMode="stateVisible|adjustResize"
after this i can't edit the text fields
if inputType:number then it works
One thing i want to add more is i'm using this in custom ListView
I think problem with android:textIsSelectable="true" try to remove and check
<EditText
android:id="#+id/quantity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Quantity 1Kg Meat etc"
android:focusableInTouchMode="true"
android:clickable="true"
android:inputType="text"
android:textSize="14sp"
android:textColor="#android:color/black"
android:textColorHint="#android:color/black"
android:layout_below="#+id/line1"
android:layout_alignParentStart="true" />
android:inputType="textNoSuggestions|text"
android:focusable="true"
Working solution
If mobile text prediction is on then use above inputType to edit textfields
In below given image username hint never ever shown when I open this sign-in page, also tried to focus out. But that can not help me out. Please find this.
Here's my EditText code:
<EditText android:id="#+id/mobile_id_signin"
android:layout_width="match_parent" android:layout_height="45dp"
android:background="#drawable/edittext_shape_wight"
android:drawableLeft="#drawable/signin_username"
android:drawablePadding="15dp" android:gravity="left|center"
android:focusableInTouchMode="true"
android:descendantFocusability="beforeDescendants"
android:hint="UserName />
add this code in root layout because your activity gaining automatic focus on start
android:focusable="true"
android:focusableInTouchMode="true"
Use this code it is working and show proper hint.
<EditText android:id="#+id/mobile_id_signin"
android:layout_width="match_parent" android:layout_height="45dp" android:drawablePadding="15dp"
android:gravity="left|center" android:focusableInTouchMode="true"
android:descendantFocusability="beforeDescendants" android:hint="#string/user_name" />
I don't know why is this happening.. In other activities EditText is working fine. This is how my fragment layout looks:
<EditText
android:gravity="center"
android:inputType="text"
android:background="#android:color/transparent"
android:layout_below="#+id/profile_image"
android:text="Dusan Dimitrijevic"
android:layout_centerHorizontal="true"
android:textSize="18sp"
android:layout_marginTop="20dp"
android:textColor="#android:color/black"
android:id="#+id/et_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
Is something affecting in layout these EditTexts so they can't be editable. If i need to show you Java code, let me know. I can set text to EditText by the way, but can't edit it..
Remove the background and the text. Use hint instead of text
<EditText
android:gravity="center"
android:inputType="text"
android:hint="Dusan Dimitrijevic"
android:layout_below="#+id/profile_image"
android:layout_centerHorizontal="true"
android:textSize="18sp"
android:layout_marginTop="20dp"
android:textColor="#android:color/black"
android:id="#+id/et_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
I encountered this and resolved by identifying an overlapping layout/element declared below editText thus preventing interaction with the editText element. My editText element envelop (parent) layout had the same:
android:layout_below="#+id/xxxxxx"
specification as the layout below it.
In Below Mentioned Code i am not able to see the hint text in nexus phone, in other phone it is working fine, and looks according to code.
<android.support.design.widget.TextInputLayout
android:id="#+id/til"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
app:hintTextAppearance="#style/TextAppearence.App.TextInputLayout">
<com.hul.humarashop.CustomFontTextView.EditTextGothamBook
android:id="#+id/editName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#00000000"
android:hint="Name"
android:padding="10dp"
android:singleLine="true"
android:textColor="#000000"
android:textColorHint="#000000"
android:textSize="15sp"></com.hul.humarashop.CustomFontTextView.EditTextGothamBook>
</android.support.design.widget.TextInputLayout>
Set the app:hint="Name" on the TextInputLayout, rather than the EditText.
Just to note as well - you might like to know that the TextInputLayout has a getEditText() method! This means you only have to use one id in the xml, tidying up the code a little.
I have a EditText look like this in my layout xml and it's not expanding when the user hit enter
<EditText
android:layout_height="40dp"
android:layout_width="fill_parent"
android:gravity="top"
android:maxLines="10"
android:minHeight="40dp"
android:id="#+id/edSearch"
android:layout_toLeftOf="#+id/btnSearch"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:hint="City..."
/>
but when i changed android:layout_height="40dp" to android:layout_height="wrap_content" the the edittext is able to expand as the user hit enter.
how I can keep my EditText expanding while keeping this line android:layout_height="40dp"
Thanks
Try this
<EditText
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="Top"
android:maxLines="10"
android:minHeight="40dp"
android:id="#+id/edSearch"
android:layout_toLeftOf="#+id/btnSearch"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:inputType="textMultiLine"
android:hint="City..."
/>
Hope this will work
I'm using following code and it's working great. to set minimum height instead of setting layout_height to 40dp set it wrap_content and set attribute of minLines to achieve this as show below in code example
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textMultiLine"
android:minLines="4"
android:maxLines="10"
/>
Set property android:multiline="true".
hope this will help you.
Set android:multiline="true" along with android:gravity="left|top"