PlacePicker doesn't pick up material theme

后端 未结 3 1380
既然无缘
既然无缘 2021-01-17 21:30

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.<

3条回答
  •  孤街浪徒
    2021-01-17 22:05

    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:

    
    

    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:

    
    

提交回复
热议问题