Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@alexjlockwood
Last active December 7, 2020 18:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexjlockwood/b74fc1be361d041867ae8118ef4806fa to your computer and use it in GitHub Desktop.
Save alexjlockwood/b74fc1be361d041867ae8118ef4806fa to your computer and use it in GitHub Desktop.
Clip paths in VectorDrawable vs. SVG. The `svg_demo.svg` and `vector_drawable_demo.xml` files both have the appearance shown in `demo.png`. As you can see from each file's content, the syntax for expressing clip paths in SVGs vs. VectorDrawables is much different. View the commit that inspired this gist here: https://j.mp/2JYio7I.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<!-- A Vector Drawable w/ a ton of clip paths. Exported by Shape Shifter. -->
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<clip-path
android:name="mask1"
android:pathData="M 0 0 L 20 0 L 20 20 L 0 20 L 0 0 Z"/>
<group android:name="group1">
<clip-path
android:name="mask2"
android:pathData="M 4 4 L 24 4 L 24 24 L 4 24 L 4 4 Z"/>
<path
android:name="path1"
android:pathData="M 0 0 L 24 0 L 24 24 L 0 24 L 0 0 Z"
android:fillColor="#ff0000"/>
<clip-path
android:name="mask3"
android:pathData="M 8 8 L 16 8 L 16 16 L 8 16 L 8 8 Z"/>
<clip-path
android:name="mask4"
android:pathData="M 10 10 L 12 10 L 12 12 L 10 12 L 10 10 Z"/>
<path
android:name="path2"
android:pathData="M 0 0 L 24 0 L 24 24 L 0 24 L 0 0 Z"
android:fillColor="#0000ff"/>
</group>
<group android:name="group2">
<clip-path
android:name="mask5"
android:pathData="M 0 0 L 2 0 L 2 2 L 0 2 L 0 0 Z"/>
<clip-path
android:name="mask6"
android:pathData="M 1 1 L 3 1 L 3 3 L 1 3 L 1 1 Z"/>
<path
android:name="path3"
android:pathData="M 0 0 L 24 0 L 24 24 L 0 24 L 0 0 Z"
android:fillColor="#00ff00"/>
</group>
<path
android:name="path4"
android:pathData="M 17 0 L 21 0 L 21 3 L 17 3 L 17 0 Z"
android:fillColor="#00ffff"/>
</vector>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment