当前位置: 动力学知识库 > 问答 > 编程问答 >

android - Warning when creating shape in xml

问题描述:

I am trying to define a shape in an XML doc as follows:

<shape xmlns:android="http://schemas.android.com/apk/res/android"

android:shape="rectangle">

<gradient android:startColor="#FFFFFF"

android:endColor="#00FF00"

android:angle="270" />

<corners android:radius="3dp" />

<stroke android:width="5px" android:color="#000000" />

</shape>

However, I get the following warnings and errors:

  1. Layout width and height to be defined (no example shows these as

    being defined)

  2. Element corners not allowed here
  3. element stroke not allowed here

How can I clear these errors?

网友答案:

That XML file should be located in res/drawable. Given the errors you just mentioned I assume it is located in res/layout, which is an incorrect location.

网友答案:

I had the same problem due to the fact that i surrounded the same code with tag "selector", it was put automatically from android studio. "selector" must be changed with "shape" for have border and avoid warning

分享给朋友:
您可能感兴趣的文章:
随机阅读: