Reputation: 561
I am trying to change the bottom line colour of EditText but it is showing default blue line colour.I failed to understand where am I going wrong?
<EditText
android:id="@+id/searchtext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="15dp"
android:textColor="#000000"
android:layout_alignParentTop="true"
android:maxLines="1"
android:singleLine="true"
android:layout_toLeftOf="@+id/usericonlayout"
android:padding="7dp"
android:layout_marginTop="10dp"
android:hint="Search for all GIFs"
android:textColorHint="#A0A0A0"
android:shadowColor="@color/border_gray"
android:theme="@style/EditTextStyle"/>
styles.xml
<style name="AppBaseTheme" parent="android:Theme.Light">
<item name="colorAccent">@color/border_gray</item>
<item name="android:editTextStyle">@style/EditTextStyle</item>
</style>
<style name="AppTheme" parent="AppBaseTheme">
<item name="colorAccent">@color/border_gray</item>
<item name="android:editTextStyle">@style/EditTextStyle</item>
</style
<style name="EditTextStyle" parent="Widget.AppCompat.EditText">
<item name="colorControlNormal">@color/border_gray</item>
<item name="colorControlActivated">@color/border_gray</item>
<item name="colorControlHighlight">@color/border_gray</item>
</style>
I also tried -
edittext.getBackground().setColorFilter(getResources().getColor(R.color.border_gray), PorterDuff.Mode.SRC_ATOP);
but didn't worked
Upvotes: 6
Views: 19804
Reputation: 2467
I think you are trying to implement material design in your app. First of all there should be only two values folder in your res folder. 1. values (For version < 21) 2. values-v21
styles.xml for version < 21
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
....
<item name="android:editTextStyle">@style/EditTextStyle</item>
</style>
<style name="EditTextStyle" parent="Widget.AppCompat.EditText">
<item name="colorControlNormal">@color/border_gray</item>
<item name="colorControlActivated">@color/border_gray</item>
<item name="colorControlHighlight">@color/border_gray</item>
</style>
And for v21
<style name="AppBaseTheme" parent="@android:style/Theme.Material.Light">
.....
// Your style here
</style>
Upvotes: 5
Reputation: 1261
here it is..
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableBottom="@color/yourColor"/>
Upvotes: -1
Reputation: 3518
If you are using Api lvl >= 21, then you have to put the "android:" namespace in front of every attribute you listed.
If you are using AppCompat, you have to change your Theme's parent to:
@style/Theme.AppCompat.Light
Upvotes: 0