Android Studio 1.4渲染新抽屉模板中的问题
作者:互联网
我刚刚更新到Android Studio 1.4.我创建了一个新项目,目标SDK设置为Marshmellow.当我创建一个新的导航抽屉活动时,我可以在虚拟设备上运行该活动.但是,预览窗格中不会显示任何XML布局.
以下是错误:
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开发的新手,当默认模板像这样抛出错误时,它不是引入新框架的最佳方式:(
即使是出现问题的解释也会有所帮助.谢谢.
解决方法:
转到应用 – > res – >值 – > style.xml
然后在父级前添加“Base”一词.
例如,在添加关键字“Base”之前
父= “Theme.AppCompat.Light.DarkActionBar”
添加关键字后
父= “Base.Theme.AppCompat.Light.DarkActionBar”
有关更多信息,请参阅此YouTube视频https://youtu.be/Ox7TvRJR_Ds?t=57s
标签:android,android-studio,navigationview 来源: https://codeday.me/bug/20190702/1357761.html