元素形状没有必需属性android:layout_height

Lor*_*enz 6 xml android

我正在使用一个shape元素作为视图的背景,就像这个问题一样.我正在使用Android Studio,它告诉我......

Element shape doesn't have required attribute android:layout_height

Element shape doesn't have required attribute android:layout_width

代码如下:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

<solid android:color="@color/darkBrown"/>
<stroke android:layout_width="match_parent" android:layout_height="match_parent"/>
<corners android:radius="10dip"/>
<padding android:left="0dip" android:right="0dip" android:top="0dip" android:bottom="0dip"/>

</shape>
Run Code Online (Sandbox Code Playgroud)

基本上我的问题是:如果形状在技术上不需要这些属性,为什么会出现此错误?如何告诉android停止将其标记为错误或如何避免它?

谢谢.

已解决:原因是因为它不在drawable文件夹中.

编辑:是的我知道中风部分是不正确的.

Lor*_*enz 23

显示错误的原因是因为它不在drawable文件夹中.(layout当我drawable在拼写错误后重命名文件夹时,它自动移动到.)