Home > Java > javaTutorial > body text

How to Customize EditText Appearance with AppCompat v7?

Barbara Streisand
Release: 2024-11-01 21:09:02
Original
989 people have browsed it

How to Customize EditText Appearance with AppCompat v7?

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>
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!