ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

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

2019-07-02 16:11:34  阅读:239  来源: 互联网

标签:android android-studio navigationview


我刚刚更新到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

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有