Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change appcompat autocomplete popup text color?

I know there is a lot of questions, with answers, but none of them works for me.

My styles and themes:

<style name="AnnaTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!--
    Colors,
    and stuff
    -->
    <item name="android:dropDownItemStyle">@style/DropDownItemStyle</item>
    <item name="android:spinnerDropDownItemStyle">@style/DropDownItemStyle</item>
    <item name="spinnerDropDownItemStyle">@style/DropDownItemStyle</item>
</style>

<style name="DropDownItemStyle" parent="Widget.AppCompat.Light.DropDownItem.Spinner">
    <item name="android:textColor">@android:color/black</item>
</style>

But the result is still this:

White dropdown

The layout is this:

<android.support.design.widget.TextInputLayout
    android:id="@+id/til_email"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

        <AutoCompleteTextView
            android:id="@+id/et_email"
            android:layout_width="@dimen/join_field_width"
            android:layout_height="wrap_content"
            android:hint="@string/email"
            android:inputType="textEmailAddress"/>

</android.support.design.widget.TextInputLayout>

And the adapter:

emailView.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, Utils.getUniqueEmailsFromAccount(this)));

Can you guys help me how to make the text black?

like image 636
Pitel Avatar asked Oct 19 '22 22:10

Pitel


1 Answers

Try this advice then...

First try to change your Adapter to this (if it didn't work try with the second option :

emailView.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_dropdown_item_1line, Utils.getUniqueEmailsFromAccount(this)));


1# Create a style as follows :

<style name="CustomAuto">
    <item name="android:paddingTop">3dp</item>
    <item name="android:paddingRight">5dp</item>
    <item name="android:paddingBottom">3dp</item>
    <item name="android:paddingLeft">5dp</item>
    <item name="android:textColor">#000</item>
</style>

2# Create a Layout as follows :

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/any_id"
style="@style/CustomAuto"
android:singleLine="true" />

3# Change your Adapter to :

emailView.setAdapter(new ArrayAdapter<>(this,R.layout.text_custom_view, Utils.getUniqueEmailsFromAccount(this)));
like image 78
Skizo-ozᴉʞS Avatar answered Oct 22 '22 01:10

Skizo-ozᴉʞS