Late to the party,Here's is my answer,
This is for the people who are not looking to change the colorAccent
in their parent theme,but wants to change EditText
attributes!
This answer demos how to change ......
- Bottom line color
- Cursor color
- Cursor pointer color (I used my custom image).......... of
EditText
using style applied to the Activity theme.
<android.support.v7.widget.AppCompatEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hey" />
Example:
<style name="AppTheme.EditText" parent="@style/Widget.AppCompat.EditText">
<item name="android:textColor">@color/white</item>
<item name="android:textColorHint">#8AFFFFFF</item>
<item name="android:background">@drawable/edit_text_background</item> // background (bottom line at this case)
<item name="android:textCursorDrawable">@color/white</item> // Cursor
<item name="android:textSelectHandle">@drawable/my_white_icon</item> // For pointer normal state and copy text state
<item name="android:textSelectHandleLeft">@drawable/my_white_icon</item>
<item name="android:textSelectHandleRight">@drawable/my_white_icon</item>
</style>
Now create a drawable(edit_text_background
) add a resource xml for the background!You can customize as you want!
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:bottom="0dp"
android:left="-3dp"
android:right="-3dp"
android:top="-3dp">
<shape android:shape="rectangle">
<stroke
android:width="1dp"
android:color="@color/white"/>
</shape>
</item>
</layer-list>
Now as you did set this style in your Activity theme.
Example :
In your Activity you have a theme,set this custom editText
theme to that.
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Your Theme data -->
<item name="editTextStyle">@style/AppTheme.EditText</item> // inculude this
</style>