Reputation: 857
Edittext setError method is not showing text in android 6.0 but working perfectly in android 5.0. I have tried many solutions but don't get solution and i tried all solution of Android 6 EditText.setError not working correctly, So how to fix this issue?
This is my xml:
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar_create_page"
android:fillViewport="false">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="180dp"
android:id="@+id/ivPageBanner"
android:src="@drawable/bg_timeline"
android:scaleType="fitXY" />
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:id="@+id/ivPageDp"
android:layout_alignParentBottom="false"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="140dp"
android:layout_marginLeft="15dp"
android:src="@drawable/flagwithcamera" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/etPageName"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/ivPageDp"
android:layout_marginTop="20dp"
android:hint="Page name"
style="@style/EditTextTheme"
android:theme="@style/EditTextTheme"
android:textCursorDrawable="@drawable/black_cursor"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:textColorHint="@color/hint_foreground_material_light" />
</RelativeLayout>
</ScrollView>
Here is my style for Edittext:
<style name="EditTextTheme" parent="Widget.AppCompat.EditText">
<item name="android:textColor">@color/transparent</item>
<item name="android:textColorHint">@color/transparent</item>
<item name="colorAccent">@color/colorPrimary</item>
<item name="colorControlNormal">@color/colorPrimary</item>
<item name="colorControlActivated">@color/colorPrimary</item>
</style>
and here is my Colors.xml:
<color name="colorPrimary">#64100b</color>
<color name="transparent">#fc000000</color>
Upvotes: 1
Views: 1335
Reputation: 857
I got my solution. Just removed this from my Edittext:
android:theme="@style/EditTextTheme"
Reason is underline below text of setError.
Alright, but where are these underlines come from?
android:theme
is an attribute of View and when you set a style as android:theme
, that style will be wrapped by ContextThemeWrapper with context theme while in inflation of view.
So that means, if you set android:theme
property with style that contains android:background
item like
<item name="android:background">@color/red</item>
every child view of this theme owner will be have a green background.
"Widget.AppCompat.EditText"
is a style and references ?attr/editTextBackground
as a "android:background"
. And in v21/values-21.xml file @drawable/abc_edit_text_material
is defined as editTextBackground
.
Thanks to https://stackoverflow.com/a/42355788/5909385
Upvotes: 4
Reputation: 164
I think, It does showing but it is bit chopped off. Try using Floating Labels & Set Error to TextInputLayout reference. Please let me know if you still facing issue
Upvotes: 1