A need to draw an "X" in a View
using Shapes, but the X's edges must be anchored on left, top, right and bottom of the view.
Something like this:
By xml at drawable:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<rotate
android:fromDegrees="135"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="135">
<shape android:shape="line">
<stroke android:width="1dp" android:color="@color/social_grey" />
</shape>
</rotate>
</item>
<item>
<rotate
android:fromDegrees="45"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="45">
<shape android:shape="line">
<stroke android:width="1dp" android:color="@color/social_grey" />
</shape>
</rotate>
</item>
</layer-list>
With padding:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:left="4dp"
android:right="4dp"
>
<rotate
android:fromDegrees="135"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="135">
<shape android:shape="line">
<stroke android:width="1dp" android:color="@color/social_grey" />
</shape>
</rotate>
</item>
<item
android:left="4dp"
android:right="4dp"
>
<rotate
android:fromDegrees="45"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="45">
<shape android:shape="line">
<stroke android:width="1dp" android:color="@color/social_grey" />
</shape>
</rotate>
</item>
</layer-list>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With