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

问题描述

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

PlacePicker文档指出: b
$ b

我有我的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活动采用我的主题?

解决方案

这是。

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


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

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.

EDIT:Seems to be fixed now.

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

10-16 20:57