Drawing shapes with XML

Put your problem here if it does not fit any of the other categories.

Drawing shapes with XML

Postby robisen » Tue Mar 04, 2008 9:12 am

In the API examples there is a example called ShapeDrawable1.java that essentially draws a bunch of shapes in XML using the tag <shape></shape>. It seems like though you can only draw rectangles? Can you draw other shapes? If so where is this documented?

Thanks,

Robi
robisen
Junior Developer
Junior Developer
 
Posts: 14
Joined: Thu Feb 21, 2008 10:57 pm

Top

Postby plusminus » Tue Mar 04, 2008 1:47 pm

Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

XML tag information

Postby robisen » Tue Mar 04, 2008 5:09 pm

Thanks I had found that same information but I am looking for information on what tags and attributes I can use in XML to define a shape for example:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <shape xmlns:android="http://schemas.android.com/apk/res/android"
  2.  
  3. type="OvalShape" >
  4.  
  5.         <solid android:color="#00000000"/>
  6.  
  7.         <padding android:left="10sp" android:top="4sp" android:right="10sp"
  8.  
  9. android:bottom="4sp" />
  10.  
  11.         <stroke android:width="1dp" android:color="#FFFFFFFF"/>
  12.  
  13.        
  14.  
  15. </shape>
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


just produces a white rectangle. I would assume it would produce a Oval. Also I am not sure what other tags i can use to define. I would assume there would be a radius tag or something but cannot seem to find anything in the documentation to that effect.

Thanks,

Robi
robisen
Junior Developer
Junior Developer
 
Posts: 14
Joined: Thu Feb 21, 2008 10:57 pm

Postby plusminus » Tue Mar 04, 2008 7:25 pm

Hello robisen,

instead of:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. type="OvalShape"
Parsed in 0.000 seconds, using GeSHi 1.0.8.4

it is probably:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. type="oval"
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


yes there are like <corner>-tags to be used then.

This is said to work:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="UTF-8"?>
  2.  
  3. <shape xmlns:android="http://schemas.android.com/apk/res/android"
  4.  
  5. type="rectangle" android:background="@drawable/
  6. tuktuk_background_focus">
  7.  
  8.         <solid android:background="@drawable/tuktuk_background_focus"/>
  9.  
  10.         <padding android:left="10sp" android:top="4sp" android:right="10sp"
  11.  
  12. android:bottom="4sp" />
  13.  
  14.         <stroke android:width="1dp" android:color="#FFFFFFFF"/>
  15.  
  16.         <corners android:radius="5dp" />
  17.  
  18. </shape>
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

List of XML tags and Attributes

Postby robisen » Tue Mar 04, 2008 7:55 pm

Thanks for the response and I have tried oval, ring, etc but it seems like only rectangle does something. I think oval and ring might work if i can figure out what other associated tags or attributes must go with the shape tag but if you just use oval in the way you describe you will get a rectangle. Same with ring.

Also my real question is if their is a list of XML tags and attributes for shape? Maybe is should look for the Scheme which I assume is in the SDK?

Thanks,

Robi
robisen
Junior Developer
Junior Developer
 
Posts: 14
Joined: Thu Feb 21, 2008 10:57 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 24 guests