Changing EditText bottom line color with appcompat v7
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
On AppCompat-based Android screens, the underline under an EditText is usually tint-driven rather than defined by a simple static border color. That is why changing one XML attribute often seems to work in one state and fail in another. The real fix depends on whether you want a global theme-level answer or a one-off override for a specific field.
Understand What Actually Colors the Bottom Line
With AppCompat widgets, the underline is typically tinted using theme attributes such as colorControlNormal and colorControlActivated.
In practical terms:
- Unfocused state usually follows
colorControlNormal. - Focused state usually follows
colorControlActivated. - Error or accent-heavy themes may also involve
colorAccentdepending on widget style and Android version.
If you only change one color in the wrong place, the widget can still switch back to another theme tint on focus.
Theme-Level Solution for Consistent App Styling
If you want all EditText fields to behave consistently, set the tint colors in your AppCompat theme.
Then use normal EditText or AppCompatEditText in layout:
This is the cleanest option when the design system wants one consistent input style across the app.
Style a Single Field Without Changing the Whole Theme
If only one input should have different underline colors, use a style or tint on that widget instead of changing the global theme.
This is useful in screens with special branding or step-specific highlights. It is also safer than changing theme attributes when only one field should differ.
On some layouts you may also see android:backgroundTint. For AppCompat widgets, app:backgroundTint is usually the safer choice because it keeps the tint behavior consistent through the support library.
Programmatic Tint Update
If the underline color should react to validation or runtime state, update the tint in code.
This is useful when you want to switch between normal and error colors after validation runs.
State-Based Colors with Color Selectors
For focus-aware behavior, define a selector instead of one flat color.
Then apply it as background tint:
This gives predictable visual transitions between focus states without custom drawables.
When TextInputLayout Is the Better Choice
If the screen already uses Material-style inputs, TextInputLayout often gives more consistent underline, hint, and error behavior than trying to patch raw EditText styling.
If you are already deep into AppCompat v7 code, this may be a migration step rather than an immediate fix, but it usually reduces theme inconsistency over time.
Debugging Inconsistent Results
If tint changes do not appear:
- Confirm the view is actually
AppCompatEditText. - Check whether the theme overrides your per-view tint.
- Test both focused and unfocused states.
- Make sure design support or Material components are not applying a different parent style.
Underline rendering differences across API levels are common, so test on at least two Android versions before assuming the problem is solved.
Common Pitfalls
- Changing
colorAccentonly and expecting all underline states to update. - Styling one
EditTextwhile the theme re-tints it on focus. - Using the wrong widget class and missing AppCompat tint support.
- Forgetting to test state transitions such as focus and error.
- Forcing complex custom drawables when tint-based styling would be simpler.
Summary
- AppCompat
EditTextunderline color is usually theme- and tint-driven. - Use theme attributes for app-wide consistency.
- Use
backgroundTintorsupportBackgroundTintListfor per-field customization. - Use a color selector when focused and normal states need different colors.
- Consider
TextInputLayoutwhen richer Material input behavior is needed.

