找不到样式“mapViewStyle”在当前主题中
我正在制作一个使用谷歌地图的应用程序。但在我的 xml 中,我收到错误“无法在当前主题中找到样式‘mapViewStyle’。”相反,我已授予互联网权限并在应用程序标记内使用谷歌地图库。
任何人都可以帮我解决这个问题吗?
非常感谢
以下是我的xml文件...
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<com.google.android.maps.MapView
android:id="@+id/mapview1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="0ACHOtlugQlOP_-siR3LLyIBjv1SwpKWimIY8jw" />
</Relativelayout>
I am making an app which uses google maps. But in my xml I get th error "Failed to find style 'mapViewStyle' in current theme." Instead I have given onternet permission and used the google maps library inside the application tag.
Can anybody help me over this.
Thanks a lot
following is my xml file...
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<com.google.android.maps.MapView
android:id="@+id/mapview1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="0ACHOtlugQlOP_-siR3LLyIBjv1SwpKWimIY8jw" />
</Relativelayout>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(11)
我的回答可能有点晚了,但我希望它能解决实际原因,并确保它对那些将来要搜索相同问题的人有所帮助。
此类错误,
可能是上面列表中的任何错误,
最终原因是,
我们为
layout
选择了不可用的Theme
。这可能是因为,
主题
在themes.xml
文件中不可用。主题
属于较高版本的sdk
,但我们当前的目标sdk
是较低版本的。通常会发生此问题
layout
文件并尝试在您的project
中实现它时, 。一个。您可能忘记复制
themes.xml
文件b.您可能拥有较低的
目标 sdk
,而使用较高的目标 sdk
创建的原始布局
。此问题的解决方案是,
(在
图形布局视图
中打开并查看layout
文件,然后查看在右上角。已选择
布局
的主题
。)主题
选择的下拉列表,然后选择可用的主题 根据您的项目
主题
和目标 sdk 主题
。(或)
主题
是自定义
主题,并且您需要它,则复制themes.xml
将layout xml
文件从源复制到您的项目。(或)
主题
是sdk
可用主题
,如果您需要它,则更改您的目标
根据您选择的主题
。希望,这可能对某人有帮助。
My answer may be a late one, but i hope that it'll deals with the actual reason and sure it could be helpful for those who are going to search about the same problem in future.
This type of errors,
Anything from the above list it may be,
The ultimate reason is ,
We have selected the unavailable
Theme
for thelayout
.This may cause because of,
theme
is not available inthemes.xml
file.theme
is belongs to higher versionsdk
, but our current targetsdk
is lower one.This problem mostly happens,
layout
file and try to implement it in yourproject
.a. Your may forgot to copy
themes.xml
fileb. You may have lower
target sdk
, the originallayout
created with highertarget sdk
.The Solutions for this problem are,
(Open and View the
layout
file in theGraphical Layout View
, and look at the top Right corner.There your
themes
for thelayout
have been selected.)theme
selection and choose the availablethemes
according to your projectthemes
andtargeted sdk themes
.(OR)
theme
is acustom
one , if you are required it , then copy thethemes.xml
file to your project from the source where you copied thelayout xml
file.(OR)
theme
issdk
availtheme
, if you are required it , then change yourtarget
according to your selectedtheme
.Hope,This might be helpful for somebody.
不知道为什么,但如果您添加显式样式并在 /values/styles.xml 中定义该样式,此错误就会消失。
styles.xml:
和布局:
似乎 com.google.android.maps.MapView 真的想要声明某种样式。
Not sure why, but if you add an explicit style and define that in /values/styles.xml this error will go away.
styles.xml:
and the layout:
Seems like com.google.android.maps.MapView really wants a style of some sort to be declared.
这些错误的另一个原因实际上可能是内部 eclipse 错误。
在这种情况下,解决这个问题的方法是:
通常值得一试(特别是当你“突然”遇到这个错误时) ,因为它不需要很多时间。尽管对于OP来说情况可能并非如此,但这仍然可以帮助其他人进行搜索。
Another reason for these errors might actually be an internal eclipse error.
In that case what does solve it is:
It usually is worth a try (esp. when you encounter this error "out of the blue"), since it does not take a lot of time. Although for the OP it might not be the case, this could still help someone else searching.
您只需将Android 2.2更改为android 3.0,
并提供 id 和用户权限以及应用程序的子项
You need to change only Android 2.2 to android 3.0,
and also give id and user-permissions and child of application
每个 Android 主题并不适合所有类型的视图。因此,我们应该为我们的视图类型选择合适的主题之一。
问题如下
如果主题不合适,将会给我们带来丢失样式的错误。
这是解决方案
1.首先选择主题栏。
2.为您的视图选择主题
3.选择主题后按确定。
如果主题适合您的视图如果没有,它将呈现,然后选择另一个主题并尝试,直到找到适合您的应用程序的主题。
只要您的主题合适,它就会呈现如下图所示。
Every android theme is not suitable for every type of view. Because of this we should select one of the suitable themes for our view type.
Here is how problems looks
If theme is not suitable it will give us missing styles error.
Here is the solution
1.Firstly select theme bar.
2.Select theme for your view
3.After selecting theme then press ok.
If the theme is suitable for your view it will render if not then select another theme and try until you find a suitable theme for your application.
Whenever your theme is suitable it will render as like the picure below.
如果您的图形布局使用 Android 3.0 及更高版本。尝试将其更改为 Android 2.2 或 2.3。
If you are using Android 3.0 and above on your Graphical Layout. Try changing it to Android 2.2 or 2.3.
发生此错误的原因是 mapViewStyle 缺少某些图标或属性。如果您曾经在Android设备上应用过任何自定义主题,那么您可能会遇到诸如“缺少资产”或“主题编译不正确”等错误。这些错误是由于缺少用于手机每种外观的图标或布局,例如按钮、菜单、状态栏等。mapViewStyle
的情况类似。在项目创建过程中,您可能已经为应用程序选择了默认主题。该主题缺少 mapViewStyle 的某些组件,例如按钮图标或样式(只是给出想法,我不知道这是否属实)。我想你可能已经明白了这一点。
现在要删除错误,请进入
res>values>styles.xml
删除上一个主题行并放入这个
上面的示例只是为了让您理解并让您对问题。我并不是说它 100% 正确。
如果这个答案有用,请将其标记为有用。
This error happens due to the fact that some icons or property are missing for mapViewStyle. If you have ever applied any custom theme on android device then you might have faced error like "missing assets" or "theme improperly compiled" etc. These error arises due to lack for icons or layout for each and every look of phone such as button, menus, status bar etc.
Similar is the case with the mapViewStyle. During the project creation you might have selected a default theme for your application. This theme is missing certain components for mapViewStyle such button icon or style (Just giving the idea, I don't know if this is true or not). I think you might have understood the point.
Now to remove the error go into
res>values>styles.xml
remove the previous theme line and put this one
The above example is just for making you understand and give you a broad idea of the problem. I don't state that it's 100% true.
if this answer is useful then mark it as useful.
确保您已将自定义主题部分添加到 res 下不同值文件夹下的所有其他 styles.xml 中。
我遇到了类似的问题。就我而言,我在 res 下的
values-large
文件夹中添加了一个自定义主题。它在运行时工作,但在 Eclipse 中给出了与您一样的错误。所以我尝试在所有其他 styles.xml 文件中添加自定义部分(在我的例子中,styles.xml 文件中总共添加了 3 个标签)。即
values-normal-hdpi
、values-normal-mdpi
、valuse-v11
和values-v14< 下的 styles.xml 文件/code>...然后轰隆隆!!!
它解决了我浪费一整天的问题。
Make sure you have added your custom theme part in all other styles.xml present under different values folder under res.
I had similar problem. In my case I had added a custom theme in
values-large
folder under res. And it was working at runtime but giving error as yours in eclipse.So i tried adding the custom part(in my case totally there was 3 tags added to styles.xml file) in all other styles.xml file. i.e. styles.xml files under
values-normal-hdpi
,values-normal-mdpi
,valuse-v11
andvalues-v14
... And BOOM!!!It solved my problem which wasted my whole day.
确保不同值下存在的所有其他 styles.xml 包含您的自定义主题部分。
我也遇到了类似的问题。
就我而言,我在 res 下的
values-large
文件夹中添加了一个自定义主题。它在运行时工作,但在 Eclipse 中给出了与您一样的错误。
所以我尝试在所有其他 styles.xml 文件中添加自定义部分(在我的例子中,styles.xml 文件中总共添加了 3 个标签)。即
values-normal-hdpi
、values-normal-mdpi
、valuse-v11
和values-v14< 下的 styles.xml 文件/code>...
然后轰隆隆!!!它解决了我浪费一整天的问题。
Make sure your all other styles.xml present under different values contains your custom theme part.
I had similar problem.
In my case I had added a custom theme in
values-large
folder under res.And it was working at runtime but giving error as yours in eclipse.
So i tried adding the custom part(in my case totally there was 3 tags added to styles.xml file) in all other styles.xml file. i.e. styles.xml files under
values-normal-hdpi
,values-normal-mdpi
,valuse-v11
andvalues-v14
...And BOOM!!! It solved my problem which wasted my whole day.
虽然我确信这并不适合所有人,但对我来说,我只是将预览窗口中的主题更改为 Theme.AppCompat.Light。
在某些情况下,似乎只需设置正确的主题即可解决问题。从所有这些选择中选择哪个主题?首先选择兼容性主题;之后,祝你好运!
While I'm sure this won't work for everyone, but for me I simply changed the Theme in the Preview Window to Theme.AppCompat.Light.
It seems the in some cases merely setting the correct theme is the solution. Which theme out of all those choices? Go for the compatibility themes first; after that, good luck!
单击“预览”上的“刷新”按钮刷新 xml 布局,或者关闭 xml,然后再次打开它解决我的问题
Refresh the xml layout by click Refresh button on Preview or close the xml then open it again fix my problem