Search code examples
androidandroid-studiokotlinandroid-custom-viewdrawable

Is there a way to make a drawable or a custom view with a diagonal line in android studio?


Well, I want to do a drawable or a custom view like this. Does anyone know if there is a way to do this? I could not find. Ignore the "12:00", i just want to do an background with this diagonal line.

enter image description here


Solution

  • <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
        <item>
            <shape android:shape="rectangle">
    
                <corners android:radius="6dp" />
                <solid android:color="#f5f5f5" />
            </shape>
        </item>
        <item>
            <rotate
                android:fromDegrees="25"
                android:pivotX="50%"
                android:pivotY="50%"
                android:toDegrees="25">
                <shape android:shape="line">
                    <stroke
                        android:width="1dp"
                        android:color="#e0e0e0" />
                </shape>
            </rotate>
        </item>
    </layer-list>