I am using a PlacePicker library from Google Play Services which starts up a new activity. The new activity/picker has a toolbar (actionbar) which is not styled by default.<
As is mentioned in the documentation that you provided in your question:
If you set custom colors in your application using the material theme, the place picker inherits the colorPrimary and colorPrimaryDark attributes from the theme.
However, you have not specified the actual Material theme (Theme.Material.Light
) in your style.xml
file; rather, you have utilized Theme.AppCompat.Light
which, while it is designed to look and operate the same as the Material theme, is a support library designed to provide backward compatability for the Material theme all the way to Android 2.1 (API 7). My guess would be that the PlacePicker
library only inherits the colorPrimary
and colorPrimaryDark
attributes from the true Material theme and not the support library.
An easy way to test this would be to modify your style.xml
file to use the real Material theme and see if this works:
<style name="AppTheme" parent="android:Theme.Material">
<item name="android:colorPrimary">#5665bb</item>
<item name="android:colorPrimaryDark">#41456b</item>
</style>
The only drawback of course is that the Material theme is only available in API ≥ 21, so, if this works, then you would be restricted to devices that utilize Lollipop only.
Lastly, as a sidenote, the Theme.AppCompat
support libraries do not use the android:
namespace, so your original style.xml
file can be shortened as follows:
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="colorPrimary">#5665bb</item>
<item name="colorPrimaryDark">#41456b</item>
</style>
To fix issues toolbar theme android Place Picker on OS under Lollipop
PlacePicker.IntentBuilder intentBuilder = new PlacePicker.IntentBuilder();
Intent intent = intentBuilder.build(getActivity());
// if Build version sdk is under Lollipop, add intent extra
(Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
intent.putExtra("primary_color", getResources().getColor(R.color.colorPrimary));
intent.putExtra("primary_color_dark", getResources().getColor(R.color.colorPrimaryDark));
}
//start intent
startActivityForResult(intent, REQUEST_PLACE_PICKER_CODE);
This is an acknowledged issue by the development team.
There is currently a known issue with setting custom theme colors on the PlacePicker. For now you can work around this by defining two colors with the names "primary" and "primary_dark" - these will be applied to the PlacePicker.
Unfortunately setting the primary/primaryDark property on a theme will not affect the PlacePicker styling at the moment.
EDIT: Seems to be fixed now.
This should be fixed in Google Play Services 10.0. Place Picker and Autocomplete Widget will use the colorPrimary and colorPrimaryDark colors from your app.