找不到与给定名称匹配的资源:attr 'android:elevation'
No resource found that matches the given name: attr 'android:elevation'
我正在尝试在 VS 和 Xamarin 上重建 Android 应用程序
但是我得到这个错误
No resource found that matches the given name: attr
'android:elevation'.
这是属性:
<item name="android:elevation">@dimen/design_bottom_sheet_modal_elevation</item>
我使用这些值进行编译:
错误来自文件values.xml,但有时文件中的不同属性也会出现相同的错误;值-23.xml 或 22..etc
将编译版本更改为Android5.0或以上。
elevation 属性是在 5.0 中引入的。
所以 Kit-kat 构建工具将失败。
Elevation 仅适用于 Android 5.x+ 因此您必须更改编译以使用 5.0 或更高版本。
你的 /Resources/values/style.xml 应该看起来差不多像:
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="MyTheme" parent="MyTheme.Base">
</style>
<style name="MyTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
<item name="windowNoTitle">true</item>
<!--We will be using the toolbar so no need to show ActionBar-->
<item name="windowActionBar">false</item>
<!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette-->
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">#00FFAA</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#004D40</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">@color/accent</item>
<!-- You can also set colorControlNormal, colorControlActivated
colorControlHighlight and colorSwitchThumbNormal.
<item name="colorControlNormal">#00897B</item>
<item name="colorControlActivated">#1DE9B6</item>-->
<item name="windowActionModeOverlay">true</item>
</style>
</resources>
同时检查 /Resources/values 文件夹中的 style.xml 并确保为 API 级别 v21+ 设置样式,如下所示:/Resources/values-v21/style.xml
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<!--
Base application theme for API 21+. This theme replaces
MyTheme from resources/values/styles.xml on API 21+ devices.
-->
<style name="MyTheme" parent="MyTheme.Base">
<item name="android:windowContentTransitions">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
<item name="android:windowSharedElementExitTransition">@android:transition/move</item>
</style>
</resources>
在所有 style.xml 和图像文件的 BuildAction 中将 属性 设置为 AndroidResource。请记住,所有文件都必须位于 .Droid 项目的 Resources 文件夹中。
我正在尝试在 VS 和 Xamarin 上重建 Android 应用程序 但是我得到这个错误
No resource found that matches the given name: attr 'android:elevation'.
这是属性:
<item name="android:elevation">@dimen/design_bottom_sheet_modal_elevation</item>
我使用这些值进行编译:
错误来自文件values.xml,但有时文件中的不同属性也会出现相同的错误;值-23.xml 或 22..etc
将编译版本更改为Android5.0或以上。 elevation 属性是在 5.0 中引入的。 所以 Kit-kat 构建工具将失败。
Elevation 仅适用于 Android 5.x+ 因此您必须更改编译以使用 5.0 或更高版本。
你的 /Resources/values/style.xml 应该看起来差不多像:
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="MyTheme" parent="MyTheme.Base">
</style>
<style name="MyTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
<item name="windowNoTitle">true</item>
<!--We will be using the toolbar so no need to show ActionBar-->
<item name="windowActionBar">false</item>
<!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette-->
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">#00FFAA</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#004D40</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">@color/accent</item>
<!-- You can also set colorControlNormal, colorControlActivated
colorControlHighlight and colorSwitchThumbNormal.
<item name="colorControlNormal">#00897B</item>
<item name="colorControlActivated">#1DE9B6</item>-->
<item name="windowActionModeOverlay">true</item>
</style>
</resources>
同时检查 /Resources/values 文件夹中的 style.xml 并确保为 API 级别 v21+ 设置样式,如下所示:/Resources/values-v21/style.xml
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<!--
Base application theme for API 21+. This theme replaces
MyTheme from resources/values/styles.xml on API 21+ devices.
-->
<style name="MyTheme" parent="MyTheme.Base">
<item name="android:windowContentTransitions">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
<item name="android:windowSharedElementExitTransition">@android:transition/move</item>
</style>
</resources>
在所有 style.xml 和图像文件的 BuildAction 中将 属性 设置为 AndroidResource。请记住,所有文件都必须位于 .Droid 项目的 Resources 文件夹中。