Customizing EditText Appearance with Appcompat v7
Android's AppCompat v7 library maintains consistency across various Android versions. However, users may encounter difficulties altering the appearance of EditTexts, particularly the bottom line and accent colors.
Initially, attempting to modify the edit style through android:editTextStyle was unsuccessful. Properties such as background color and text color could be changed but not the bottom line or accent colors. Exploration into custom drawable images via android:background and specific property values also proved futile.
After examining Android API 21 sources, it was hypothesized that colorControlActivated and colorControlNormal were used to control EditText appearance. Overriding these properties in the EditText style, however, had no effect.
Finally, a solution was discovered. By overriding colorControlActivated, colorControlHighlight, and colorControlNormal in the app theme definition, the desired color customizations could be achieved.
<style name="Theme.App.Base" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="colorControlNormal">#c5c5c5</item> <item name="colorControlActivated">@color/accent</item> <item name="colorControlHighlight">@color/accent</item> </style>
Applying this theme to an activity will result in the desired EditText appearance.
The above is the detailed content of How to Customize EditText Appearance with AppCompat v7?. For more information, please follow other related articles on the PHP Chinese website!