Skip to content

Instantly share code, notes, and snippets.

@vxhviet
Created November 5, 2019 09:27
Show Gist options
  • Save vxhviet/90a42c260806e6549174b8de26bfbee6 to your computer and use it in GitHub Desktop.
Save vxhviet/90a42c260806e6549174b8de26bfbee6 to your computer and use it in GitHub Desktop.

Question: Is it possible to create an Android shape object with stroke on only certain sides?

SOURCE

Answer:

Use the inset tag and give a negative value for the side border you want to remove.

<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
    android:insetLeft="-2dp">
    <shape android:shape="rectangle">
        <corners
            android:bottomLeftRadius="0dp"
            android:bottomRightRadius="5dp"
            android:topLeftRadius="0dp"
            android:topRightRadius="5dp" />
        <stroke
            android:width="1dp"
            android:color="@color/line_border_box" />
    </shape>
</inset>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment