Search code examples
androidlineselector

How to draw a line with one bending end


ow

How can I draw such a horizontal line (bending upward from the left end) as shown in the above image in the XML file through a selector? below is my selector file code. Thank you

<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="1dip" android:color="@color/md_black_1000" />
<solid

    android:color="#ffffff"
    />
<corners
    android:topLeftRadius="15px"
    android:bottomLeftRadius="15px"
    />

<padding
    android:top="3dp"
    android:bottom="3dp"
    />
</shape>

Solution

  • I believe you can achieve this effect only for specific cases, for example, when you had fixed item height:

    <?xml version="1.0" encoding="utf-8"?>
    <inset xmlns:android="http://schemas.android.com/apk/res/android"
        android:insetTop="-2dp"
        android:insetRight="-2dp">
        <shape>
            <corners android:bottomLeftRadius="80dp" />
            <stroke android:width="2dp" />
        </shape>
    </inset>
    
    <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        tools:context=".MainActivity">
    
        <TextView
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:text="Item"
            android:gravity="center_vertical"
            android:paddingLeft="16dp"
            android:paddingRight="16dp"
            android:background="@drawable/selector"/>
    
    </FrameLayout>
    

    And then:

    enter image description here