I am creating a custom Button and I am using the Drawable.setTintList to have colors for default,pressed and disabled states.
I want to actually add a border to the button, which I am trying by doing:
val d = newGradientDrawableForShape()
d.setShape(GradientDrawable.RECTANGLE)
d.setColor(Color.WHITE)
d.setStroke(20, Color.GREEN)
With this the border is not visible, however if I do not use tint list then I do see the border.
Is there a way I can use setStroke and TintList?
I tried d.setStroke(width, colorList) and it didn't work either.
you can use drawable with state example:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<corners android:radius="4dp" />
<stroke android:width="10dp" android:color="#6699ff" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<corners android:radius="4dp" />
<stroke android:width="10dp" android:color="#669900" />
</shape>
</item>
</selector>

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