svg - Android VectorDrawable doesn't show up in the layout -


i created svg vector graphic (using coreldraw x7), looks this:

enter image description here

then used svg2android convert vectordrawable format. however, when try use in layout, doesn't appear:

enter image description here

as can see, there vector drawable right next it, works fine (so svg2android , android studio work fine).

this xml of actual drawable:

<?xml version="1.0" encoding="utf-8"?> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportwidth="24" android:viewportheight="24"> <path     android:fillcolor="#000000" android:pathdata="m 1382,680 c 107,0 194,112 194,251 0,138 -87,250      -194,250 -2,0 -3,0 -5,0 -17,98 -85,219 -230,219 l 0,77 c 0,28 235,1 235,45 l 0,55 -556,0 0,-55 c 0,-59 235,-11 235,-45 l 0,-77 c -125,0 -211,-106 -230,-219 -1,0 -3,0 -5,0 -107,0 -195,-112 -195,-250 0,-139 88,-251 195,-251 l 0,0 0,-48 556,0 0,48 z m -555,413 -1,-325 c 0,0 0,0 0,0 -70,0 -126,73 -126,163 0,89 56,162 126,162 0,0 1,0 1,0 z m 555,-325 0,325 c 70,0 126,-73 126,-162 0,-90 -56,-163 -126,-163 z" /> </vector> 

the thing notice different between code of file, , code of other, working files, of values in file appear negative, compared working files, positive.

what doing wrong?

the coordinates points in path way large viewportwidth , viewportheight specified.

the path bounding box is:

x:      631 y:      632 width:  945 height: 945 

but viewport settings telling android is:

x:      0 y:      0 width:  24 height: 24 

so shape going drawn way off edge of icon area.

there ways fix manually, better adjust coreldraw file graphic @ top left of page. make sure saved svg has viewbox. viewbox svg2android using calculate viewportwidth , viewportheight.

if can't make coreldraw generate viewbox, design icons on fixed size page (eg. 100px x 100px). should able working svg adding viewbox manually.

<svg ... viewbox="0 0 100 100" ...> 

note: i'm doing educated guessing here because don't have coreldraw test with.

in meantime, here hand-tweaked version of file think should work (i've not tested it):

<?xml version="1.0" encoding="utf-8"?> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportwidth="945" android:viewportheight="945">  <group android:translatex="-631" android:translatey="-632"> <path     android:fillcolor="#000000" android:pathdata="m 1382,680 c 107,0 194,112 194,251 0,138 -87,250      -194,250 -2,0 -3,0 -5,0 -17,98 -85,219 -230,219 l 0,77 c 0,28 235,1 235,45 l 0,55 -556,0 0,-55 c 0,-59 235,-11 235,-45 l 0,-77 c -125,0 -211,-106 -230,-219 -1,0 -3,0 -5,0 -107,0 -195,-112 -195,-250 0,-139 88,-251 195,-251 l 0,0 0,-48 556,0 0,48 z m -555,413 -1,-325 c 0,0 0,0 0,0 -70,0 -126,73 -126,163 0,89 56,162 126,162 0,0 1,0 1,0 z m 555,-325 0,325 c 70,0 126,-73 126,-162 0,-90 -56,-163 -126,-163 z" /> </group> </vector> 

Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -