Android: TextInputEditText showing text only after change focus - android

I have a big problem with a EditText that does not show any input until i change focus from element. When I click on the input, the keyboard appears and while i type, there is nothing displayed in the edit text view. The input is shown only when i close the keyboard
It is not a problem of colours. I mention that the view are contained in a constraint layout. I can enable hardware acceleration but this will slow down the application very much and it's not an option. I can however discard the constraint layout and change it to a linear layout but this will affect the rest of the code. I am sure that I am missing something, an easy fix, but i can't put my finger on it. Thanks a lot in advance
<android.support.design.widget.TextInputLayout
android:id="#+id/codeEditTextContainer"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginBottom="20dp"
app:layout_constraintBottom_toTopOf="#id/verifyButton"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent">
<android.support.design.widget.TextInputEditText
android:id="#+id/codeEditText"
android:layout_width="match_parent"
android:inputType="text"
android:layout_height="wrap_content"
android:hint="#string/sms_code"
android:padding="10dp"
android:textColor="#color/white" />
</android.support.design.widget.TextInputLayout>
!!UPDATE
Found the problem, but still i have no answer. This problem is present only on Android Pie and only when the edit text is in the lower part of the screen and has to be raised by the soft keyboard. I already tried to add softInputWindowMode to adjustResize or adjustPan but this is not doing anything.
The problem itself is a duplicate to this question Android Pie edittext does not adjustPan/resize while typing
which still doesn't have an answer

The problem man be about hardwareAccelerated. I was having the same problem and waste too much time to solve before saw this page.
Android Pie edittext does not adjustPan/resize while typing

Related

Lower TextInputEditText not displaying text while typing, only displayed after done (or) next action (or) when tapping anywhere in screen

Below is my code for EditText,
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/password_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/username_layout"
android:layout_marginTop="10dp"
android:layout_marginBottom="15dp"
app:hintEnabled="false"
app:passwordToggleEnabled="false"
app:passwordToggleTint="#color/white">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/login_password_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/login_username_input"
android:layout_weight="0.0"
android:drawableEnd="#drawable/password"
android:background="#drawable/round_bg"
android:hint="#string/login_password_hint"
android:imeActionLabel="#string/action_done"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:maxLines="1"
android:nextFocusDown="#+id/submit_btn"
android:paddingStart="10dp"
android:paddingLeft="10dp"
android:text=""
android:textColor="#FFFFFF"
android:textColorHint="#FFFFFF"
android:textCursorDrawable="#null"
tools:ignore="RtlSymmetry" />
</com.google.android.material.textfield.TextInputLayout>
I am setting password eye icon programatically like below,
passwordLayout.setEndIconMode(TextInputLayout.END_ICON_PASSWORD_TOGGLE);
passwordLayout.setEndIconDrawable(GetDrawable.getDrawable("Show/Hide Password"));
passwordLayout.setEndIconTintList(ColorStateList.valueOf(getResources().getColor(R.color.color_white)));
This works fine in most of the devices. But getting below issue in Mi a2 Android Version 10.
I have two TextInputLayout for user name and password field
There is no issue while typing username field.
Next moved to password field. Now, the cursor stucked in first position and typing text is showed up in keyboard but not displayed in Edittext field. Only text is displayed after tapping somewhere else in screen
I am not sure why this happens in some devices
Found below question related to my issue. But no solution provided there.
TextInputEditText is not showing the typed text/number when typing
UPDATE
In this given a solution for my issue, Android Pie edittext does not adjustPan/resize while typing but using Hardware acceleration may lead to high memory usage. So afraid to use this solution.
is there any other way to solve this?
I tested the code on emulator on two android devices find nothing wrong with it used com.google.android.material:material:1.3.0
please update your color style it has no Legiblity
pan Adjuesment related issued loged in debug check that
try alpha or Rc MDC for libaray version bug
Finally you do is open issue at MDC github here

Two fragments stacked ontop of each other using transactional ADD - how to prevent edit text gaining focus on bottom fragment?

Try stacking two fragments with editTexts on top of each other using an Add Transaction. after that when you press the keyboard imeOption key next button the bottom fragment's edit text can gain focus. this is a security concern. user can type things into the bottom fragments edit text (blindly). I tried the following code:
android:filterTouchesWhenObscured="true"
but it has not helped at least on api 27.
my edit text itself looks like this, nothing special:
<EditText
android:id="#+id/et"
android:layout_width="195dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:imeOptions="actionNone"
android:layout_marginBottom="10dp"
android:hint="#string/enter_name"
android:filterTouchesWhenObscured="true"
android:inputType="textNoSuggestions"
android:textColorHint="#959595"
android:textSize="11sp" />
the issue is very similar to android tap jacking
i tried even doing this:
android:nextFocusDown="#+id/et_two" thinking it would bypass and go directly to the edittext i want. but instead the bottom edit text still gains focus.
the issue solution was surprising. recyclerview was stealing focus. see this SO incident:
adding android:descendantFocusability="blocksDescendants" to the recyclerview stopped the issue.

android editText multiline return to line not working with swiftkey

I have the following edit text
<EditText
android:id="#+id/txtMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:gravity="start"
android:inputType="text|textMultiLine"
android:minHeight="90dp"
android:singleLine="false"
android:textColor="#color/textColor" />
Every reference shows that the code is correct and in fact the text wraps to multiline. But the enter key doesn't go to the new line when i use swiftkey keyboard (Google keyboard works fine)
any idea of how to solve this issue ?
Thanks
Have you considered switching to the default keyboard. It might solve your issue.
See this answer Set EditText to be Multiline(Enter is carrige return) and not display suggestions for more details.

EditText added is not a TextInputEditText. Please switch to using that class instead

I'm using an EditText inside a TextInputLayout, but after upgrading the support library to 23.2.0, I get this warning in the logcat, What's the difference between a regular EditText and a TextInputEditText? I can't seem to find any documentation for it.
I was wondering this too, Daniel Wilson gathered the documentation, but to the untrained eye it doesn't mean much. Here's what it's all about: "extract mode" is referring to the type of view that's shown when the space is too small, for example landscape on a phone. I'm using Galaxy S4 with Google Keyboard as input method editor (IME).
Landscape UI without visible IME
Based on the focus (on Description) you can see TextInputLayout in action pushing the hint outside the editor. Nothing special here, this is what TextInputLayout is supposed to do.
Landscape UI editing empty Name field
Editing the Name you can see that the IME doesn't give you a hint of what you're editing.
Landscape UI editing empty Description field
Editing the Description you can see that the IME gives you a hint of what you're editing.
Layout XMLs
The difference between the two fields is their type EditText VS TextInputEditText. The important thing here is that TextInputLayout has the android:hint and not the wrapped EditText, this is the case when TextInputEditText's few lines of Java code makes a big difference.
Name field
<android.support.design.widget.TextInputLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Item Name"
>
<EditText
android:id="#+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</android.support.design.widget.TextInputLayout>
Description field
<android.support.design.widget.TextInputLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Item Description"
>
<android.support.design.widget.TextInputEditText
android:id="#+id/description"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:minLines="4"
android:scrollbars="vertical"
/>
</android.support.design.widget.TextInputLayout>
There is no documentation for it, but the class is a regular EditText with a single extra feature:
Using this class allows us to display a hint in the IME when in 'extract' mode.
Specifically it sets the EditorInfo.hintText. You'll notice in the TextInputLayout class you can specify the hint and it's appearance rather than as part of the child EditText widget.
If you need to do that, you should use a TextInputEditText so it pays attention to the hint info you specified in the TextInputLayout.
They are essentially the same thing, but I think the TextInputEditText has more features and possibly attributes. I changed to the TextInputEditText and everything worked and looked as it did before with the standard EditText.
The only difference is that when your device is in landscape mode, TextInputEditText will show the hint, EditText won't.
I had this problem and just deleted this line in my xml file:
android: fitsSystemWindows = "true"
and the error disappeared.

How to make Android EditText expand vertically when full

I have this EditText
<EditText
android:layout_width="match_parent"
android:layout_height="72dp"
android:hint="#string/write_message"
android:textColorHint="#color/primary_color"
android:ems="10"
android:imeOptions="actionDone"
android:inputType="textImeMultiLine"
android:id="#+id/message_input"
android:layout_gravity="center_horizontal"
android:backgroundTint="#color/primary_color"/>
When the box is filled up with user inputted text, it scrolls to the right to make room for more text, I do not like this behavior, and would prefer it if the EditText box expanded upwards when it needs more room? Is there a way to do this? Thanks.
Yes, this actually involves two things:
Making the EditText accept multi-line input.
Having its height grow as more text lines are added.
Therefore, to achieve this, you need to set up:
android:inputType="textMultiLine"
android:layout_height="wrap_content"
(Be mindful of the difference between textMultiLine and textImeMultiLine).
The full XML snippet would be:
<EditText
android:layout_width="match_parent"
android:inputType="textMultiLine"
android:layout_height="wrap_content"
android:hint="#string/write_message"
android:textColorHint="#color/primary_color"
android:ems="10"
android:imeOptions="actionDone"
android:id="#+id/message_input"
android:layout_gravity="center_horizontal"
android:backgroundTint="#color/primary_color"/>
Use both flags: textMultiLine will wrap your input, and textImeMultiLine will provide a break-line key in your keyboard.
<EditText
...
android:layout_height="wrap_content"
android:inputType="textImeMultiLine|textMultiLine"
... />
In my case I have multiline text, but it showed one line and a keyboard:
Though I have already set android:inputType="textCapSentences|textAutoCorrect|textMultiLine", it didn't help. Then I understood that when the keyboard appears in DialogFragment, it collapses the EditText. See DialogFragment and force to show keyboard to show keyboard when DialogFragment shows.
Then I added a short delay (100-300 ms) before showing the keyboard. Now I have:
In AndroidManifest I set android:windowSoftInputMode="adjustResize" for current activity.

Categories

Resources