Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Styling AutoCompleteTextView with AppCompat.EditText does not work

I make material design style application

I want to change AutoCompleteTextView style
to style like in android.support.v7.internal.widget.TintEditText

I added style to my style.xml:

<style name="AppTheme" parent="AppTheme.Base"/>
<style name="AppTheme.Base" parent="Theme.AppCompat">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="android:autoCompleteTextViewStyle">@style/AutoCompleteTextViewAppTheme</item>
</style>
<style name="AutoCompleteTextViewAppTheme" parent="Base.Widget.AppCompat.EditText"/>

That works but the line colors does not change. enter image description here

EditTexts with material design seem to use colorControlActivated and colorControlNormal. Therefore, I have tried to override these properties in the previous style definition but it has no effect.
What I need to do, to make it work ?

like image 471
CodeNinja Avatar asked Dec 26 '14 16:12

CodeNinja


People also ask

Which method is used for filling the data to AutoCompleteTextView?

Android AutoCompleteTextView OverviewgetAdapter() : This method returns a filterable list adapter used for auto completion.

Which properties can control type of character in AutoCompleteTextView control?

XML attributes Defines the number of characters that the user must type before completion suggestions are displayed in a drop down menu.

How do I create an AutoCompleteTextView field in XML?

In android, we can create an AutoCompleteTextView control in two ways either manually in an XML file or create it in the Activity file programmatically. First we create a new project by following the below steps: Click on File, then New => New Project. After that include the Kotlin support and click on next.

How do I set autocomplete text on Android?

If you want to get suggestions , when you type in an editable text field , you can do this via AutoCompleteTextView. It provides suggestions automatically when the user is typing. The list of suggestions is displayed in a drop down menu from which the user can choose an item to replace the content of the edit box with.


1 Answers

Try to add the desired style to use for your widget in the xml this way :

<View
style="@style/NameOfYourTheme"
...
/>

If that doesn't work you could try to style it yourself. You will have to change the TextView attributes which you can look up here.

Textcolor for an instance could be changed by changing the android:textColor attribute which should be added to your style, for example :

<style name="AutoCompleteTextViewAppTheme" parent="Base.Widget.AppCompat.EditText"/>

<item name="android:textColor">#ffffffff</item>
</style>

If you want to change the edittext line you have to change the background attribute, for example in this manner :

<item name ="android:background="@drawable/line_background"> </item>

And add a new file line_background.xml in your drawables folder with a similar content:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="line">


    <stroke
        android:color="#c0c000"
        android:width="3dp"></stroke>
</shape>
like image 81
throws_exceptions_at_you Avatar answered Nov 12 '22 17:11

throws_exceptions_at_you