Warning when creating shape in xml

I am trying to define a form in an XML document 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:

  • The width and height of the layout should be defined (not a single example shows them as determined)
  • Element angles are not allowed here.
  • Element bar is not allowed

How can I fix these errors?

+4
source share
2 answers

This XML file must be in res/drawable . Given the errors you just mentioned, I assume it is in res/layout , which is the wrong location.

+6
source

I had the same problem due to the fact that I surrounded the same code with the tag "selector", it was automatically placed in android studio. the "selector" must be changed using the "form" for the border and prevent the warning

0
source

Source: https://habr.com/ru/post/1494205/


All Articles