XML : How to draw complex diagrams using xml in Android

I saw similar questions here , here , here and also in some other websites.

I know to draw shapes using xml like below code

  <?xml version="1.0" encoding="utf-8"?>  <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" >      <gradient android:startColor="#FFFF0000" android:endColor="#80FF00FF"          android:angle="270"/>  </shape>    

But, I saw a code while seeing this tutorial , they have used xml to draw a flight.

I thought it was a png file but then i saw it is an XML . Below is the code

  <vector xmlns:android="http://schemas.android.com/apk/res/android"          android:width="24dp"          android:height="24dp"          android:viewportWidth="24.0"          android:viewportHeight="24.0">      <path          android:fillColor="#FF000000"          android:pathData="M10.18,9"/>      <path          android:fillColor="#FF000000"          android:pathData="M21,16v-2l-8,-5V3.5c0,-0.83 -0.67,-1.5 -1.5,-1.5S10,2.67 10,3.5V9l-8,5v2l8,-2.5V19l-2,1.5V22l3.5,-1 3.5,1v-1.5L13,19v-5.5l8,2.5z"/>  </vector>    

I just wonder what that pathData and its contents M21,16v-2l-8,-5V3.5c0... means.

Can you explain it ?

And my next doubt is, How can i code like that

Do we need to code it manually ( By specifying each pixel locations ) by some calculations

or

is there any trick to draw a shape by having a png image. ( Any online converter where we upload a png file and it will give us as XML code or Any other method)

Is the title of the question is correct ? I don't know what method is that. So i simply put How to draw.... Correct me if i specified anything wrong.

Thanks in advance (:

No comments:

Post a Comment