- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 Android Studio 中启动了一个新项目并配置了我的 gradle build设置。当我将 android.support.v7.widget.Toolbar 添加到布局时,在设计 View 中出现以下错误。请注意,此错误仅在使用小于 21 的 API(特别是 API 16 - 19)进行预览时出现。当我使用 API 21 - 24 预览时一切正常。
我看过很多解决方案并尝试过,但没有一个能解决问题。我尝试做的一件事是将其添加到我的 gradle 中:
vectorDrawables.useSupportLibrary = true
但这并没有解决问题。我尝试将 compiledSdkVersion 配置为 23,将 buildToolsVersion 配置为 23.0.3。这并没有改变任何东西。如果我将支持库版本更改为 23.4.0 或更低版本,那么问题就解决了。一旦我将它改回 24.0.0 或更高版本,它就会返回。
清除缓存、清理项目并重建、使缓存失效并重新启动都没有解决问题。
The following classes could not be instantiated:
- android.support.v7.widget.Toolbar (Open Class, Show Exception, Clear Cache)
Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when in the IDE
Exception Details
java.lang.IllegalStateException: This app has been built with an incorrect configuration.
Please configure your build for VectorDrawableCompat.
at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:692)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:186)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:181)
at android.support.v7.widget.TintTypedArray.getDrawable(TintTypedArray.java:67)
at android.support.v7.widget.Toolbar.<init>(Toolbar.java:298)
at android.support.v7.widget.Toolbar.<init>(Toolbar.java:229)
...
invalid drawable tag vector
这是我的应用程序 build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1" // https://developer.android.com/studio/releases/build-tools.html
defaultConfig {
applicationId "org.path.path"
minSdkVersion 16
targetSdkVersion 23
versionCode 0
versionName "0.0.0"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
ext {
supportLibVersion = '24.0.0' // https://developer.android.com/topic/libraries/support-library/revisions.html
}
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile "com.android.support:appcompat-v7:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
compile "com.android.support:cardview-v7:${supportLibVersion}"
compile "com.android.support:recyclerview-v7:${supportLibVersion}"
}
我的项目 build.gradle 正在使用 classpath 'com.android.tools.build:gradle:2.1.2'
这是工具栏 xml:
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar_main"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:minHeight="?attr/actionBarSize"
android:elevation="4dp"
android:background="@color/colorPrimary"
app:theme="@style/ActionBarThemeOverlay"
app:popupTheme="@style/ActionBarPopupThemeOverlay"/>
最后,我的 styles.xml:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<!-- ActionBar -->
<style name="ActionBarPopupThemeOverlay" parent="ThemeOverlay.AppCompat.Dark" />
<style name="ActionBarThemeOverlay" parent="ThemeOverlay.AppCompat.Dark">
<item name="android:textColorPrimary">@color/text_on_primary</item>
<item name="android:textColorSecondary">@color/subtitle_on_primary</item>
</style>
这是一个错误,还是我无法使用 24 或更高版本的支持库?我不知道有任何其他配置要更改,因为异常试图指示。
最佳答案
关于android.support.v7.widget.Toolbar VectorDrawableCompat 使用支持库时出现 IllegalStateException 24+,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38650995/
这是工具栏布局的 XML... 我正在使用支持库将工具栏用作我的操作栏。我在 onCreate 中这样做了... Toolbar mToolbar = (Toolbar)getLayoutInf
是否有任何属性/配置表明工具栏在向右溢出时应滚动到最后一项?我有一个垂直工具栏。它应该滚动到右侧的最后一项 我的配置如下: var toolbar = Ext.create('Ext.toolbar.
我使用 toolbar.Template() 和 Toolbar.Excel() 但 toolbar.excel() 不显示,只是 toolbar.Template() 显示。 .Excel(exce
我试图将 justify-content:center 放在工具栏内容的中心。在定位工具栏时,我可以看到扩展的元素,其中之一是 md-toolbar-row 给 justify-content:cen
我有一个toolbar.xml: 我的另一个 Activity 布局有一个包含标签: 我已经在我的扩展 AppCompatActivity 的 Activity 中实现了它: Toolbar
这是主要 Activity ,如 您可以清楚地看到 import android.support.v7.widget.Toolbar; 已经存在。 package app.com.example.an
我正在使用 TabLayout 折叠 ToolbarLayout,除了向上滚动时我的选项卡没有卡在工具栏下方之外,一切正常。 下面是我的代码:
有人可以向我解释一下它们之间的区别以及为什么它们不能互换吗? 导入 android.widget.Toolbar 会导致编译错误,而导入 android.support.v7.widget.Toolb
我收到这个错误 Caused by: java.lang.ClassCastException: android.support.v7.widget.Toolbar cannot be cast t
我正在寻找一种干净的方法来调整 Material-UI AppBar 后面的内容的偏移量。 我认为 theme.mixins.toolbar 会自动适应,但事实并非如此。 (使用这里描述的主题密度 P
我试过很多方法。但没有工作。期待这样的风格 ion-toolbar { contain: none; .toolbar-container { overflow: vi
我想在 md-toolbar 中使用 mf-tabs,我使用 Sithdown 在 https://github.com/angular/material/issues/1076 中提供的解决方案 它
Django 1.10 django-debug-toolbar == 1.5 新项目(我刚刚安装了Django)。尝试安装Django调试工具栏。 文档:https://django-debug-t
我正在升级我之前制作的一款游戏的用户界面,并且正朝着 Google 的 Material Design 方向发展。作为代码升级的一部分,我将向后兼容性支持库 android-support-v7-ap
您好,我是 Xamarin 的新手,我试图在 MainActivity 的 OnCreate() 中找到一个 View ,但找不到它(?)并且返回为 null。 protected override
是否可以将SAS脚本或宏分配给基本SAS中的工具栏按钮?即可以'dm'宏或sas脚本吗? 最佳答案 当然。这是一种方法: 转到“工具”->“自定义”。 选择“自定义”选项卡 通过单击“添加工具”(最左
我创建了一个简单的ALV网格,并用数据填充了网格,现在在选择屏幕之后显示了该网格。我没有使用自定义容器,而是以全屏显示网格。 是否有ALV网格对象的属性,该属性使工具栏具有通常位于网格顶部的按钮过滤器
我想为我的网站制作一个像谷歌工具栏这样的浏览器工具栏。它应该与所有流行的浏览器兼容。 我应该使用哪种语言来制作它?我可以使用任何示例/指南吗? 最佳答案 对于 Firefox,从这里开始:https:
我新下载了一个 jupyter 并尝试使用它。 但是,使用我的 mac 和 windows 计算机, 我在 jupyter 中看不到工具栏。 我尝试搜索以解决此问题,并尝试在 Mac 和 window
我在我的应用程序中使用工具栏。它应该如下所示: 但是,有时候,工具栏背景是错误的!我不知道为什么会这样...... 这是我的布局: ...... 这是我的工具栏: 帮助!有什么想法吗? 设备
我是一名优秀的程序员,十分优秀!