2

How to give colors for autocompletetextview in android. I am using these two colors for background and text-color

android:background = "#000000" android:textclolor = "#ffffff".

But the problem is if i type some texts on autocompletetextview then the listable values are showing in white color and same to the text-colors too.

I can't able to fix only a color for the whole autocompletetextview. How to do this?

suggestions please!..

thanks in advance

prabu
  • 717
  • 3
  • 12
  • 30

3 Answers3

15

you can use android:popupBackground attributes in AutoCompleteTextView in layout xml. it works for your problem. As for example like this ...

<?xml version="1.0" encoding="utf-8"?>
<AutoCompleteTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/autocomplete_country"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#000000"
android:popupBackground="#ffffff"  />
SAURABH_12
  • 2,262
  • 1
  • 19
  • 19
2

you can do it at runtime like

 AutoCompleteTextView searchView = ... 
searchView.setDropDownBackgroundDrawable(new ColorDrawable(context.getResources().getColor(R.color.colorId)));

and if you want to hange it in your xml file then you have to give android:popupBackground property to your Autocomplete view.

enjoy your code:)

John smith
  • 1,781
  • 17
  • 27
0

To set the popup background use popupBackground xml property for AutoCompleteTextView. I also advice you to use Themes for text colors, sizes etc. When you want to style a list on the AutoCompleTextView popup (for example change a divider) you can do it from theme settings like that:

<item name="android:dropDownListViewStyle">@style/MyListViewStyle</item>
Mark
  • 5,466
  • 3
  • 23
  • 24