简体   繁体   中英

Android SVG and Viewport

I have an SVG and it always seems the w/h (100/100) is always the same as the viewport sizes. If I change the viewport to be less it always starts at 0,0 and goes to 50,50

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="100dp"
android:height="100dp"
android:viewportWidth="100"
android:viewportHeight="100"> 

尺寸 100x100,视口 100x100

here is half the sizes and you get 1/4 the image, the top left.

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="100dp"
android:height="100dp"
android:viewportWidth="50"
android:viewportHeight="50">

尺寸 100x100,视口 50x50

What if I wanted to have the viewport take it from the middle and cut off the padding? Like this. How would I do this.

我想要的居中视口

There are a couple of solutions:

The simplest is probably to load the SVG into a vector editor and move the shapes up into the corner; resize the document; then save out the new SVG

Or you could manually add android:translateX and android:translateY attribute to the elements you want to move. I can't tell you which elements you need to modify (or by how much) because you haven't posted the whole file. You'll also need to update the android:viewportWidth and android:viewportHeight accordingly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM