https://kotlinlang.org logo
#splitties
Title
# splitties
n

nickk

08/09/2019, 12:04 PM
One of the most irritating things in Android is adding a shadow or rounded corners. I haven’t spotted anything that makes this easier in Splitties (without using CardViews). Is there something? Or could we build it? Like, say,
view { cornerRadius = 3 }
or
view { shadowRadius = 2 }
l

louiscad

08/09/2019, 1:12 PM
There's none because I never tried to add a shadow to a view or edit its corner radius. But since you're in code, if you get to a Kotlin extension, you can use it straighaway (and share it here, can be interesting). (I can't tell now if it could be added to Splitties as I don't know the underlying APIs required yet.)
i

ispbox

08/09/2019, 5:44 PM
I'm still using xml styles for that 🙂 Something like in \drawable
Copy code
<?xml version="1.0" encoding="utf-8"?>
<ripple
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="?android:colorControlHighlight">
    <item>
        <shape android:shape="rectangle">
            <corners android:radius="3dp" />
            <solid android:color="@android:color/white" />
        </shape>
    </item>
</ripple>
and just use this style in button creation:
Copy code
setBackgroundResource(R.drawable.ripple)
In this way I get nice ripple effect, rounded corners and some shadow.
2 Views