找不到样式“mapViewStyle”在当前主题中

发布于 2024-12-03 19:00:04 字数 911 浏览 3 评论 0原文

我正在制作一个使用谷歌地图的应用程序。但在我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

來不及說愛妳 2024-12-10 19:00:04

我的回答可能有点晚了,但我希望它能解决实际原因,并确保它对那些将来要搜索相同问题的人有所帮助。

此类错误,

1. Android Google Maps Failed to find style 'mapViewStyle' in current theme
2. Failed to find style 'imageButtonStyle' in current theme 
3. Failed to find style 'editTextStyle' in current theme 
4. Failed to find style 'textViewStyle' in current theme 

可能是上面列表中的任何错误,

最终原因是,

我们为 layout 选择了不可用的 Theme

这可能是因为,

  1. 所选的主题themes.xml文件中不可用。
  2. 所选的主题属于较高版本的sdk,但我们当前的目标sdk是较低版本的。

通常会发生此问题

  1. 当您复制整个 layout 文件并尝试在您的 project 中实现它时, 。
    一个。您可能忘记复制 themes.xml 文件
    b.您可能拥有较低的目标 sdk,而使用较高的目标 sdk 创建的原始布局

此问题的解决方案是,

(在图形布局视图打开查看layout文件,然后查看在右上角。
已选择布局主题。)

  1. 因此,单击主题选择的下拉列表,然后选择可用的主题 根据您的项目主题目标 sdk 主题
    (或)
  2. 如果主题自定义主题,并且您需要它,则复制themes.xmllayout xml 文件从源复制到您的项目。
    (或)
  3. 如果主题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,

1. Android Google Maps Failed to find style 'mapViewStyle' in current theme
2. Failed to find style 'imageButtonStyle' in current theme 
3. Failed to find style 'editTextStyle' in current theme 
4. Failed to find style 'textViewStyle' in current theme 

Anything from the above list it may be,

The ultimate reason is ,

We have selected the unavailable Theme for the layout.

This may cause because of,

  1. The selected theme is not available in themes.xml file.
  2. The selected theme is belongs to higher version sdk, but our current target sdk is lower one.

This problem mostly happens,

  1. when you copy the whole layout file and try to implement it in your project.
    a. Your may forgot to copy themes.xml file
    b. You may have lower target sdk, the original layout created with higher target sdk.

The Solutions for this problem are,

(Open and View the layout file in the Graphical Layout View, and look at the top Right corner.
There your themes for the layout have been selected.)

  1. So click the dropdown list for theme selection and choose the available themes according to your project themes and targeted sdk themes.
    (OR)
  2. If the theme is a custom one , if you are required it , then copy the themes.xml file to your project from the source where you copied the layout xml file.
    (OR)
  3. If the theme is sdk avail theme, if you are required it , then change your target according to your selected theme.

Hope,This might be helpful for somebody.

眼趣 2024-12-10 19:00:04

不知道为什么,但如果您添加显式样式并在 /values/styles.xml 中定义该样式,此错误就会消失。

styles.xml:

<style name="mapView">
    <item name="android:gravity">center</item>
</style>

和布局:

<com.google.android.maps.MapView
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"
    android:apiKey="YOUR_API_KEY"
    android:visibility="visible"
    style="@style/mapView"
/>

似乎 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:

<style name="mapView">
    <item name="android:gravity">center</item>
</style>

and the layout:

<com.google.android.maps.MapView
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"
    android:apiKey="YOUR_API_KEY"
    android:visibility="visible"
    style="@style/mapView"
/>

Seems like com.google.android.maps.MapView really wants a style of some sort to be declared.

倾城花音 2024-12-10 19:00:04

这些错误的另一个原因实际上可能是内部 eclipse 错误

在这种情况下,解决这个问题的方法是:

  1. 关闭xml布局文件
  2. 重新启动eclipse(或者甚至是ADT,因为我听说它也在那里发生)

通常值得一试(特别是当你“突然”遇到这个错误时) ,因为它不需要很多时间。尽管对于OP来说情况可能并非如此,但这仍然可以帮助其他人进行搜索。

Another reason for these errors might actually be an internal eclipse error.

In that case what does solve it is:

  1. closing the xml layout file
  2. restarting eclipse (or even ADT as I heard it happens there as well)

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.

他是夢罘是命 2024-12-10 19:00:04

您只需将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

污味仙女 2024-12-10 19:00:04

每个 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.

enter image description here

Here is the solution

1.Firstly select theme bar.

enter image description here

2.Select theme for your view

enter image description here

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.
enter image description here

Oo萌小芽oO 2024-12-10 19:00:04

如果您的图形布局使用 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.

强辩 2024-12-10 19:00:04

发生此错误的原因是 mapViewStyle 缺少某些图标或属性。如果您曾经在Android设备上应用过任何自定义主题,那么您可能会遇到诸如“缺少资产”“主题编译不正确”等错误。这些错误是由于缺少用于手机每种外观的图标或布局,例如按钮、菜单、状态栏等。mapViewStyle

的情况类似。在项目创建过程中,您可能已经为应用程序选择了默认主题。该主题缺少 mapViewStyle 的某些组件,例如按钮图标或样式(只是给出想法,我不知道这是否属实)。我想你可能已经明白了这一点。

现在要删除错误,请进入 res>values>styles.xml

删除上一个主题行并放入这个

<style name="AppBaseTheme" parent="android:Theme.Light">

上面的示例只是为了让您理解并让您对问题。我并不是说它 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

<style name="AppBaseTheme" parent="android:Theme.Light">

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.

〃温暖了心ぐ 2024-12-10 19:00:04

确保您已将自定义主题部分添加到 res 下不同值文件夹下的所有其他 styles.xml 中。

我遇到了类似的问题。就我而言,我在 res 下的 values-large 文件夹中添加了一个自定义主题。它在运行时工作,但在 Eclipse 中给出了与您一样的错误。
所以我尝试在所有其他 styles.xml 文件中添加自定义部分(在我的例子中,styles.xml 文件中总共添加了 3 个标签)。即 values-normal-hdpivalues-normal-mdpivaluse-v11values-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 and values-v14... And BOOM!!!
It solved my problem which wasted my whole day.

欢烬 2024-12-10 19:00:04

确保不同值下存在的所有其他 styles.xml 包含您的自定义主题部分。

我也遇到了类似的问题。

就我而言,我在 res 下的 values-large 文件夹中添加了一个自定义主题。
它在运行时工作,但在 Eclipse 中给出了与您一样的错误。

所以我尝试在所有其他 styles.xml 文件中添加自定义部分(在我的例子中,styles.xml 文件中总共添加了 3 个标签)。即 values-normal-hdpivalues-normal-mdpivaluse-v11values-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 and values-v14...

And BOOM!!! It solved my problem which wasted my whole day.

匿名的好友 2024-12-10 19:00:04

虽然我确信这并不适合所有人,但对我来说,我只是将预览窗口中的主题更改为 Theme.AppCompat.Light

主题删除-down 红色圆圈

在某些情况下,似乎只需设置正确的主题即可解决问题。从所有这些选择中选择哪个主题?首先选择兼容性主题;之后,祝你好运!

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.

Theme Drop-down Circled in Red

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!

木緿 2024-12-10 19:00:04

单击“预览”上的“刷新”按钮刷新 xml 布局,或者关闭 xml,然后再次打开它解决我的问题

Refresh the xml layout by click Refresh button on Preview or close the xml then open it again fix my problem

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文