gpt4 book ai didi

android - PlacePicker 不选择 Material 主题

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:03:39 26 4
gpt4 key购买 nike

我正在使用 Google Play 服务中的 PlacePicker 库来启动新 Activity 。新的 Activity/选择器有一个默认没有样式的工具栏(actionbar)。

PlacePicker 文档指出

If you set custom colors in your application using the material theme,the place picker inherits the colorPrimary and colorPrimaryDarkattributes from the theme.

我的 style.xml 文件中有一个主题:

<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="colorPrimary">#5665bb</item>
<item name="android:colorPrimary">#5665bb</item>
<item name="colorPrimaryDark">#41456b</item>
<item name="android:colorPrimaryDark">#41456b</item>
</style>

并且我已经设置了要在我的 Android Manifesto 文件中使用的主题

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >

placepicker 由以下代码创建:

try {
PlacePicker.IntentBuilder intentBuilder = new PlacePicker.IntentBuilder();
Intent intent = intentBuilder.build(Main.this);
// Start the intent by requesting a result,
// identified by a request code.
startActivityForResult(intent, REQUEST_PLACE_PICKER);
} catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
Log.e("", "Error with Google Play lib.");
}

但是,工具栏没有样式。和以前一样,它具有白色背景和黑色文本。有趣的是,我自己的工具栏 (actionbar) 确实有样式。

如何强制 placepicker Activity 采用我的主题?

最佳答案

这是一个 acknowledged issue由开发团队。

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.

编辑:现在似乎已修复。

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.

关于android - PlacePicker 不选择 Material 主题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29733340/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com