Android Studio 1.4 新抽屉模板渲染问题

标签 android android-studio navigationview

我刚刚更新到 Android Studio 1.4。我创建了一个目标 SDK 设置为 Marshmellow 的新项目。当我创建一个新的 Navigation Drawer Activity 时,我可以在虚拟设备上运行该 Activity 。但是,没有任何 XML 布局显示在预览 Pane 中。

以下是错误: activity_main.xml:

Rendering Problems 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. NOTE: One or more layouts are missing the layout_width or layout_height attributes. These are required in most layouts. Or: Automatically add all missing attributes The following classes could not be instantiated: - android.support.design.widget.NavigationView (Open Class, Show Exception, Clear Cache) Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE Exception Details android.content.res.Resources$NotFoundException: Could not find bool resource matching value 0x7F090006 (resolved name: abc_config_showMenuShortcutsWhenKeyboardPresent) in current configuration.   at android.content.res.BridgeResources.throwException(BridgeResources.java:841)   at android.content.res.BridgeResources.getBoolean(BridgeResources.java:610)   at android.support.v7.internal.view.menu.MenuBuilder.setShortcutsVisibleInner(MenuBuilder.java:790)   at android.support.v7.internal.view.menu.MenuBuilder.(MenuBuilder.java:227)   at android.support.design.internal.NavigationMenu.(NavigationMenu.java:34)   at android.support.design.widget.NavigationView.(NavigationView.java:99)   at android.support.design.widget.NavigationView.(NavigationView.java:92)   at java.lang.reflect.Constructor.newInstance(Constructor.java:422)   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)   at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:835)   at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)   at android.view.LayoutInflater.rInflate(LayoutInflater.java:811)   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)   at android.view.LayoutInflater.inflate(LayoutInflater.java:515)   at android.view.LayoutInflater.inflate(LayoutInflater.java:394) Copy stack to clipboard Failed to find style 'toolbarStyle' in current theme (8 similar errors not shown)

app_bar_main.xml:

Rendering Problems 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. NOTE: One or more layouts are missing the layout_width or layout_height attributes. These are required in most layouts. Or: Automatically add all missing attributes Failed to find style 'toolbarStyle' in current theme (8 similar errors not shown)

content_main.xml:

Rendering Problems 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. NOTE: One or more layouts are missing the layout_width or layout_height attributes. These are required in most layouts. Or: Automatically add all missing attributes Failed to find style 'toolbarStyle' in current theme (8 similar errors not shown)

nav_header_main.xml:

Rendering Problems 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. Couldn't resolve resource @style/ThemeOverlay.AppCompat.Dark (3 similar errors not shown) Failed to find style 'textViewStyle' in current theme (2 similar errors not shown)

由于提到缺少样式,这里是我的 styles.xml:

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

我是 Android 开发的新手,当默认模板像这样向您抛出错误时,这不是引入新框架的最佳方式:(

即使解释出了什么问题也会有所帮助。谢谢。

最佳答案

我遇到了同样的问题,我认为最好的解决办法是点击“自动添加所有缺失的属性”链接。然后,一切都会正常工作。

关于Android Studio 1.4 新抽屉模板渲染问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32895224/

相关文章:

java - 如何创建点击文本的处理程序?

android - 微调器 setOnItemSelectedListener 不触发

android - 即使将 "with only the traditional scheme"设置为 false 后也无法签署 apk 'v2SigningEnabled'

Android 导航组件在通过 NavigationDrawer 导航时有延迟

android - 在导航 View 之间添加分隔线

android - 如何在代码中更改 NavigationView 菜单中 MenuItems 的顺序?

android - 更新到 XE16 后,Google map 库无法在 Google Glass 中运行

android - 如何开发android图像失真

android - 什么是概念和规范文件,它们可以从 android studio 中的文件 -> 新建创建?

java - 将 java 库添加到 android 项目会出现顶级异常