3
\$\begingroup\$

I've created my first Android drawable, a hourglass shaped image, and I'm curious what can be improved with it. It seems weird having to use 4 paths, but I couldn't get it to work any other way.

<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="34dp"
        android:viewportHeight="34"
        android:viewportWidth="24">

    <group>
        <path
            android:pathData="M0,10L0,0M0,0L24,0M24,0L24,10"
            android:strokeColor="@color/ColorPrimary"
            android:strokeWidth="3"/>

        <path
            android:pathData="M0,10L24,24"
            android:strokeColor="@color/ColorPrimary"
            android:strokeWidth="1.7"/>
        <path
            android:pathData="M24,10L0,24"
            android:strokeColor="@color/ColorPrimary"
            android:strokeWidth="1.7"/>
        <path
            android:pathData="M0,24L0,34M0,34L34,34M24,34L24,24"
            android:strokeColor="@color/ColorPrimary"
            android:strokeWidth="3"/>

    </group>
</vector>

enter image description here

Reason I tagged it SVG, is the docs page mentions

android:pathData

Defines path data using exactly same format as "d" attribute in the SVG's path data. This is defined in the viewport space.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.