缺少风格.是否为此布局选择了正确的主题?

Deb*_*ari 163 android

缺少风格.是否为此布局选择了正确的主题?使用布局上方的主题组合框选择不同的布局,或修复主题样式引用.无法mapViewStyle在当前主题中找到样式.

我尝试了所有可用的解决方案来解决这个问题但似乎没有任何效果.我在清单文件中包含了库.我甚至创建了样式是styles.xml,我也选择了Google Apis构建目标.

有人可以给我一个解决方案.提前感谢您宝贵的时间.

这是我的xml文件:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
style="@style/AppTheme"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >


 <com.google.android.maps.MapView
     android:id="@+id/themap"
     style="@style/mapViewStyle"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:apiKey="here i have my key"
     android:clickable="true"
     android:enabled="true" />

  </RelativeLayout>   
Run Code Online (Sandbox Code Playgroud)

这是我的清单片段:

  <uses-library android:name="com.google.android.maps" />

    <activity
        android:name=".MainActivity"
        android:label="@string/title_activity_main" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".Second" />

    <activity android:name=".Third"  android:theme="@android:style/Theme.Black"/>
  </application>
Run Code Online (Sandbox Code Playgroud)

这是我的style.xml文件

<resources>
    <style name="mapViewStyle" parent="@android:style/Theme.Black">
    </style>
</resources>
Run Code Online (Sandbox Code Playgroud)

gbe*_*ero 151

对于Android Studio(或IntelliJ IDEA),

如果项目中的所有内容都正常,并且您仍然在布局中收到错误,请尝试"使缓存无效并重新启动".

在Android Studio重新创建缓存和索引时享用咖啡.

如何使缓存和重启无效


小智 150

我有同样的问题,发现它是图形布局编辑器顶部的主题下拉列表.我从Holo更改为Theme,显示的布局和错误消失了.

  • 我将它从"App Theme"更改为"App Compat"并将其修复为我.BTW:格栅非常适合防止小猫被扫入下水道. (19认同)

Hen*_*Zhu 14

我通常做的是以下几点:a Gradle Clean,RebuildSync all my Gradle files.之后我是restart Android Studio,我去了:

Select Theme -> Project Themes -> AppTheme
Run Code Online (Sandbox Code Playgroud)


Yul*_*mok 9

这是因为您选择的不是项目的主题.尝试下一步:

在此输入图像描述


Doo*_*gle 7

如果我们使用Android Studio创建太多项目,那么渲染问题就出现了.即使创建空白活动,我们也会收到此类渲染错误.请关闭并重新启动Android studio.如果问题仍然存在,您可以Android Studio缓存失效并重新启动

希望这可以帮助.它的工作原理与经验法则相似,如果一切看起来都很好并且仍然存在错误,应用程序的重启通常可以解决问题.