Change Google Places picker Action bar color

杀马特。学长 韩版系。学妹 提交于 2020-01-17 13:09:45

问题


Good morning, i am quite new in Android and i have a problem setting the color of the built-in action bar in Google Places Picker. The documentation of this one clearly says that the action bar color inherits the matherial theme style of the project. The problem is that i have Theme.AppCompat.Light.NoActionBar and the color of this style isn't passed to the Google Place Picker because it uses only the colors of material themes. I would like to ask if it's somehow possible to replace Theme.AppCompat.Light.NoActionBar with any material theme so i can use that to set the action bar color in place picker. I have tried in this way: styles.xml

<style name="AppTheme" parent="AppTheme.Base"/>


        <!-- Customize your theme here. -->
    <style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    </style>

v21\styles.xml

<style name="AppTheme" parent="AppTheme.Base">
        <!-- Customize your theme here. -->
        <item name="android:colorPrimary">@color/colorPrimary</item>
        <item name="android:colorPrimaryDark">@color/colorPrimaryDark</item>
    </style>

My activity extends AppCompatActivity so when i change to Material theme android throws in exception because an AppCompatStyle is needed. Thank you for the attention.


回答1:


I have found the solution for this problem: The appcompat in version > 21 extends material theme and so also this kind of style allows to modify the place picker color. To change color, you have to insert in @color the values for "primary" and "primaryDark"; this is a bug of google that isnn't still fixed.



来源:https://stackoverflow.com/questions/30523366/change-google-places-picker-action-bar-color

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!