Rounded Corners and Borders in Android Studio

Haronsku :

I want to add rounded corners and borders to a textview. But only the top corners should be rounded and the bottom should be without border. Already found this:

https://www.android-examples.com/add-rounded-border-to-textview-programmatically/

But then I have rounded corners at the bottom too.

How can I change this?

Karan Mehta :

Create a drawable file like this :

    <?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
    android:insetBottom="-4dp">

    <shape android:shape="rectangle">
        <solid android:color="#FFFFFF" />
        <stroke android:width="4dp" android:color="#000000" />
        <corners android:radius="4dp" />
    </shape>

</inset>

And then apply it as an background of any control and there you go, it's done.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=7150&siteId=1