PlacePicker不会选取材质主题 [英] PlacePicker doesn't pick up material theme

查看:194
本文介绍了PlacePicker不会选取材质主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用来自Google Play服务的 PlacePicker 图书馆启动新活动。新的活动/选择器有一个工具栏(操作栏),默认情况下它不是样式。

PlacePicker文档指出: b
$ b


如果您在应用程序中使用自定义颜色材质主题
地方选择器继承了主题中的colorPrimary和colorPrimaryDark
属性。

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

 < style name =AppThemeparent =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由以下代码创建:

 尝试{
PlacePicker.IntentBuilder intentBuilder = new PlacePicker.IntentBuilder();
Intent intent = intentBuilder.build(Main.this);
//通过请求一个结果来启动意图,
//由请求代码标识。
startActivityForResult(intent,REQUEST_PLACE_PICKER);
} catch(GooglePlayServicesRepairedException | GooglePlayServicesNotAvailableException e){
Log.e(,Google Play lib错误。);
}

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



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

解决方案

这是确认问题


目前在
PlacePicker上设置自定义主题颜色时存在已知问题。现在,您可以通过定义名为primary和primary_dark的两种
颜色来解决此问题 - 这些将应用于PlacePicker的


不幸的是,在主题上设置primary / primaryDark属性
不会影响PlacePicker样式。编辑:
似乎现在已经修复。


这应该在Google Play Services 10.0中修复。 Place Picker和
Autocomplete Widget将从您的应用中使用colorPrimary和colorPrimaryDark
颜色。



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.

PlacePicker documentation states that

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

I have a theme in my style.xml file:

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

and I have set the theme to be used in my Android Manifesto file

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

The placepicker is created by the following code:

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.");
}

However, the toolbar doesn't get styled. As before it has a white background and black text. It's interesting to note that my own toolbar (actionbar) does get styled.

How do I force the placepicker activity to adopt my theme?

解决方案

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.

这篇关于PlacePicker不会选取材质主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆