Android 让我们解决“Failed to find style 'mapViewstyle' in current theme”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12023940/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Let's solve the "Failed to find style 'mapViewstyle' in current theme" error
提问by Billdr
Sorry to post yet another one of these, but it seems we have yet to document every solution to this issue.
很抱歉再次发布其中一个,但似乎我们尚未记录此问题的所有解决方案。
Here's what happened: I added a mapview, everything was working peachy. I added a slidingdrawer and moved buttons into it, then changed the root node from a linear to a relative. Since then I get an error in the Graphical Layout of my main.xml class that reads
这是发生的事情:我添加了一个地图视图,一切都很好。我添加了一个滑动抽屉并将按钮移动到其中,然后将根节点从线性更改为相对。从那时起,我在 main.xml 类的图形布局中收到一个错误,该错误显示为
Missing styles. Is the correct theme chosen for this layout? Use the Theme combo box above the layout to choose a different layout, or fix the theme style references. Failed to find style 'mapViewStyle' in current theme.
缺少样式。是否为此布局选择了正确的主题?使用布局上方的主题组合框选择不同的布局,或修复主题样式引用。无法在当前主题中找到样式“mapViewStyle”。
Toggling the root node to linear and back to relative has gotten the map to display, but the error is still in the graphical layout.
将根节点切换为线性并返回到相对已使地图显示,但错误仍在图形布局中。
So far I have done the following solutions, which may resolve the issue for most cases:
到目前为止,我已经完成了以下解决方案,它们可以解决大多数情况下的问题:
- Added a style.xml to create a 'mapView' style.
- Verified my build target is API 2.3.3 (10)
- Made sure
<uses-library android:name="com.google.android.maps"/>
is a child node of Application. - Clean/rebuilt my application.
- Deleted R.
- Deleted and rebuilt main.xml
- Restarted the adb server, Eclipse, my computer, and my device.
- Toggled between Android 3.0 and Android 2.3.3 in the Graphical Layout.
- 添加了 style.xml 以创建“mapView”样式。
- 验证我的构建目标是 API 2.3.3 (10)
- 确保
<uses-library android:name="com.google.android.maps"/>
是应用程序的子节点。 - 清理/重建我的应用程序。
- 删除了 R。
- 删除并重建 main.xml
- 重新启动 adb 服务器、Eclipse、我的电脑和我的设备。
- 在图形布局中在 Android 3.0 和 Android 2.3.3 之间切换。
However, my problem persists. Here's my layout xml.
但是,我的问题仍然存在。这是我的布局 xml。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapview"
style="@style/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:apiKey="asdf" //not my real key
android:clickable="true" />
<!-- TODO: update the API key with release signature -->
<SlidingDrawer
android:id="@+id/slidingDrawer1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:content="@+id/content"
android:handle="@+id/handle" >
<Button
android:id="@+id/handle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Menu" />
<LinearLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="@+id/about"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/about" />
<Button
android:id="@+id/record"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/record" />
<Button
android:id="@+id/start"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/start" />
</LinearLayout>
</SlidingDrawer>
</RelativeLayout>
Here is my manifest xml.
这是我的清单 xml。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="edu.myschoolhere"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<uses-library android:name="com.google.android.maps"/>
<activity
android:name=".GeoTagActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
If anyone has a solution, please let me know. I'll do my best to post back if I ever figure it out.
如果有人有解决方案,请告诉我。如果我弄清楚了,我会尽力回帖。
回答by Kartihkraj Duraisamy
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
.
我们选择了不可用Theme
的layout
.
This may cause because of,
这可能是因为,
- The selected
theme
is not available inthemes.xml
file. - The selected
theme
is belongs to higher versionsdk
, but our current targetsdk
is lower one.
- 所选文件
theme
在themes.xml
文件中不可用。 - 所选的
theme
是属于更高版本sdk
,但我们当前的目标sdk
是更低版本。
This problem mostly happens,
这个问题多半会出现
- when you copy the whole
layout
file and try to implement it in yourproject
. a. Your may forgot to copythemes.xml
file b. You may have lowertarget sdk
, the originallayout
created with highertarget sdk
.
- 当您复制整个
layout
文件并尝试在您的project
. 一种。您可能忘记复制themes.xml
文件 b。你可能有较低的target sdk
,原来layout
用较高的创造target sdk
。
The Solutions for this problem are,
这个问题的解决方案是,
(Openand Viewthe layout
file in the Graphical Layout View
, and look at the top Right corner.
There your themes
for the layout
have been selected.)
(打开并查看 中的layout
文件Graphical Layout View
,然后查看右上角。您themes
的layout
已被选中。)
- So click the dropdown list for
theme
selection and choose the availablethemes
according to your projectthemes
andtargeted sdk themes
. (OR) - If the
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) - If the
theme
issdk
availtheme
, if you are required it , then change yourtarget
according to your selectedtheme
.
- 因此,单击下拉列表进行
theme
选择,然后themes
根据您的项目themes
和targeted sdk themes
. (或者) - 如果
theme
是custom
一个,如果您需要它,则将themes.xml
文件从复制layout xml
文件的源复制到您的项目。 (或者) - 如果
theme
是sdk
无济于事theme
,如果你需要它,那么你改变target
根据您的选择theme
。
Hope,This might be helpful for somebody.
希望,这可能对某人有帮助。
回答by Harun ERGUL
This solution is for Android Studio maybe it will give an idea for Eclipse user too.
Every android theme is not suitable for every view. Because of this we should select one of the suitable themes for our view type.
此解决方案适用于 Android Studio,也许它也会为 Eclipse 用户提供一个想法。
每个 android 主题并不适合每个视图。因此,我们应该为我们的视图类型选择合适的主题之一。
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
2.为您的视图选择主题
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.
3.选择主题后按确定。
如果主题适合您的视图,它将呈现,如果不适合,则选择另一个主题并尝试直到找到适合您的应用程序的主题。
只要您的主题合适,它就会呈现如下图所示。
回答by Pramod Solanky
I was facing a similar issue.
我面临着类似的问题。
I don't know what the problem was and after searching an answer on google I found nothing of help.
我不知道问题是什么,在谷歌上搜索答案后,我没有找到任何帮助。
So What I did was deleted the activity and guess what??, it worked.
所以我所做的是删除了活动,猜猜是什么??,它起作用了。
Again, I'm not sure how did this work out but it did eventually for me.
同样,我不确定这是如何解决的,但最终对我来说确实如此。
Hope this helps.
希望这可以帮助。
回答by margo
when you create android application,you choose minimum required sdk API14.And then,you will create project successfully.This is my solution.
创建android应用程序时,选择最低要求的sdk API14。然后,您将成功创建项目。这是我的解决方案。