Android: TextInputLayouts always have an error icon - android

I have noticed that since a few days, all my TextInputLayouts have the "error exclamation point" always enabled. I haven't changed anything about those TextInputLayouts for a long time, so I really don't understand what is happening.
Here is a screenshot of how it looks:
Do you have have any idea what could be the source of this issue? Did something recently changed with the TextInputLayouts?
Thank you very much in advance
EDIT
Here is the related code:
The .xml file is really simple. It's a list of TextInputLayouts and EditTexts like this:
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/default_margin"
android:layout_marginTop="#dimen/default_margin"
android:layout_marginRight="#dimen/default_margin">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/txtAddressTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/PROFILE_SCREEN_ADDRESS_INPUT_TITLE"
android:inputType="textPersonName|textCapWords" />
</com.google.android.material.textfield.TextInputLayout>
Also, there absolutely no mention of setError() in my Kotlin code.

You can try this. But It will permanently remove the error Icon. If you want to show it again you have do it programmatically.
app:errorIconDrawable="#null"

Edit:
It looks like it's fixed with com.google.android.material:material:1.2.0-alpha04.
Ho, I found the issue. I actually updated the version of the Material library from version com.google.android.material:material:1.1.0-alpha08 to com.google.android.material:material:1.1.0-alpha09.
Google changed the behaviour of Text Field (see here: https://github.com/material-components/material-components-android/releases/tag/1.1.0-alpha09):
Text Field:
Adding option to set TextInputLayout icons to be not checkable (6a88f2b)
Implementing error icon for text fields (3f73804)

Related

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.

Have Android EditText appear to be in focus

Would it be possible to have an edit text appear to be in focus but not not actually be in focus. I would like the bright blue underline on two or more of the edit texts in my UI but never have them in focus or have the blinking insertion point. I have tried android:focusable="false" but that makes it grayed out. I'v also tried out a number of other combination but can't seem to find one that works.
Try to use
setSelected(true);
I think it will help
Edit:
To summarize I think you cannot really setSelection on multiple edittext at the same time but you can customize your editext by giving them custom background using selectors so they will look like selected.
You can accomplish it by using these tools that allow quick resources generators.
http://romannurik.github.io/AndroidAssetStudio/
Try this:
<EditText ... >
<requestFocus />
</EditText>
Hope this helps.
Programatically you can "request focus" to your view:
myEditText.requestFocus();
or via xml:
<EditText>
<requestFocus />
</EditText>

Android 4.3+, android:textColorHint doesn't work, hint color is always white

As the question says: When testing the app on devices running Android 4.3+ (also tested on 4.4), the color of the hints (for EditText) turns white, and no matter what color I set it to, it remains white. Since the EditText's background is white, the hints isn't visible to the naked eye!
I've googled and googled and can't find anyone having the same issue. The app was built using android:minSdkVersion="8" and android:targetSdkVersion="15". The EditText looks like this:
<EditText
android:id="#+id/editText3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/my_background"
android:ems="10"
android:textColorHint="#color/BlueViolet"
android:hint="#string/my_hint"
android:inputType="number"
android:tag="21_0" />
At first it was using the default android:textColorHint and I thought that maybe Android 4.3+ changed the default to white for some reason. But that doesn't seem to be the case since whatever color I set it to, it's always white.
I'm aware that fill_parent is deprecated, but the app was build quite some time ago, but is now unuseable due to hints disappearing. Any help is appreciated! Thanks!
EDIT:
The 'error' seem to occur when using a String-resource for hint. This works: android:hint="Hello world" while this doesn't android:hint="#string/my_hint"
For who struggles with same problem;
If you used your edittext in
android.support.design.widget.TextInputLayout
you should put your
android:textColorHint="#color/BlueViolet"
in TextInputLayout
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColorHint="#android:color/white">
<AutoCompleteTextView
android:id="#id/etextEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/prompt_card"
android:inputType="textEmailAddress"
android:maxLines="1"
android:singleLine="true"
android:textColor="#android:color/white"/>
</android.support.design.widget.TextInputLayout>
It seems since Android 4.3+ it's no longer possible to make String-resources as follows (not sure if it was ever meant to work this way though):
<string name="my_hint"><font size="13" fgcolor="#ffbbbbbb">Hello world</font></string>
If you do, they turn out white. So you are stuck with creating the String-resource this way:
<string name="my_hint">Hello world</string>
And then use the properties on the TextView/EditText to edit the color of the hint. To change the size, it seems it's still possible to do:
<string name="my_hint"><small><small>Hello world</small></small></string>
I found this out by reading the comment of this answer: https://stackoverflow.com/a/11577658/2422321, by Edward Falk
In addition to Erhan's answer or incase you are using the TextInputLayout widget,
I found that using app:hintTextColor instead of android:textColorHint works best

Meaning of "No label views point to this text field" warning message

What is the meaning of this warning?
No label views point to this text field with an android:labelFor="#
id/# id/editText1" attribute
Note that the double id (#id/#id) is a problem with the error message text and does not reflect the XML content (which is the correct syntax).
The labelFor is an attribute for accessibility options. You assign this to a label so that if, on a form , user clicks a textedit field , android can know what to read (TalkBack) to user.
The id you assigned to it doesn't seem to be a valid one. why there are two #id in the id? Use ids like this: #id/editText1
I've had the same warning message. It disappeared, when I added a hint to my EditText
android:hint="Some explanation about the input..."
Although I am not familiar with the exact error you have posted. But it definitely sounds like you have done something wrong with the id in the textView. Use id like following in your textView.
android:id="#+id/editText1"
And if you want to set labelFor then use :
android:labelFor="#+id/editText1"
It means that you probably should define a label for this edit text and link them using a labelFor inside that labels definition.
example code:
<TextView
android:id="#+id/my_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:labelFor="#+id/my_editText" <!--the plus sign goes first in the code-->
android:text="I'm a label" />
<EditText
android:id="#id/my_editText" <!--no plus sign if not the first-->
android:layout_width="wrap_content"
android:inputType="text"
android:layout_height="wrap_content" />
and it's not only for text views.
Remove th first '#id/' , use like
android:id="#+id/editText1"
which is the correct format. Keep going.. Best wishes.. :)
I solved it by writing both attributes:
android:id="#+id/editText1"
android:labelFor="#+id/editText1"
Select the editText, go to Properties, then Label for and enter #id/EditText1
If the XML looks correct and you're in a Graphical Layout mode then it's probably using a later version of the Android rendering layout that doesn't support EditText.
In Eclipse and Android Studio there should be a green Android icon with what API version is rendering the layout. Make sure you're using a non W or Wearable API as Android W APIs don't support the EditText element. (EditText is most likely not supported because virtual keyboard space is limited on those devices).
The rendered preview should support EditText in any API 4.X version without a trailing W.

Hyphen breaks the line into multi line

In a a custom list view, I have a textview showing name and emailId. When the name provided is something like A-TestThisString(testA#test.com), the length of displayed area exceeds,
In that case the string is broken at the place of hyphen like
A-
is shown in the list. This is causing lots of problems. I have found one link which talks about solution bellow
topic: "Android: How do i make nonbreakable block in TextView?"
but, I am not able to understand how to use it. Please suggest.
Thanks for your help. I found the answer. use the inputType as email or singleLine=True, it starts working fine.
I used android:inputType="date", no line breaks and hyphen is displayed nicely
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="2-3 4-5"
android:inputType="date"
android:textSize="25sp" />

Categories

Resources