Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Places SDK for Android: styling an Autocomplete Activity

I am using an Intent to launch an Autocomplete Activity from the Places SDK for Android, as described here, along the following lines:

Intent intent = new Autocomplete.IntentBuilder(
        AutocompleteActivityMode.FULLSCREEN, fields)
        .build(this);
startActivityForResult(intent, AUTOCOMPLETE_REQUEST_CODE);

But I cannot see a way of styling the resulting Autocomplete Activity, to make it match the theme of my app as closely as possible, and in particular to follow the day/night theme being used in the app. At present the background of the places list always appears to be white, with dark text on top, i.e. suited only to a light theme.

For example the following is what it looks like, when launched from within an app running on a system set to dark theme:

enter image description here

How is this Activity meant to be styled?

like image 787
drmrbrewer Avatar asked Sep 16 '25 06:09

drmrbrewer


1 Answers

In colors.xml file make sure you have these defined:

<resources>
   <color name="colorPrimary">#ffffff</color>
   <color name="colorPrimaryDark">#03DAC5</color>
   <color name="colorAccent">#03d</color>
</resources>

In styles.xml you should have this defined:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
   <item name="colorPrimary">@color/colorPrimary</item>
   <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
   <item name="colorAccent">@color/colorAccent</item>
</style>

With that I was able to change the colors of the Places SDK.

colorPrimary is used for the background surrounding the EditText

colorPrimaryDark is used for the status bar

Styles & Screenshot

like image 92
apmartin1991 Avatar answered Sep 18 '25 19:09

apmartin1991