Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 679
RunLoop Avatar asked Jul 30 '13 06:07

RunLoop


People also ask

What is shape in XML?

The Shape Drawable is an XML file that defines a geometric shape, including colors and gradients. This is used to create a complex shape that can then be attached as the background of a layout or a view on screen.

How to put image in drawable XML file?

To use an image resource, add your file to the res/drawable/ directory of your project. Once in your project, you can reference the image resource from your code or your XML layout. Either way, it's referred to using a resource ID, which is the file name without the file type extension. For example, refer to my_image.

How to define a drawable?

drawable (comparative more drawable, superlative most drawable) Capable of being drawn (represented graphically). Capable of being drawn (pulled or extracted). Capable of being drawn (deduced or inferred).

What types of files can be stored in the res drawable directory?

Bitmap filewebp , . jpg , or . gif file. Android creates a Drawable resource for any of these files when you save them in the res/drawable/ directory.


1 Answers

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.

like image 155
Andy Res Avatar answered Sep 28 '22 10:09

Andy Res