How can `backgroundTint` be translated to compose ...
# compose
b
How can
backgroundTint
be translated to compose buttons?
c
Depends how you’ve used it in the past. At a simple level, Button has a
colors
param that you can modify to whatever you want, including passing colors that are mixed (using the available Colors graphics APIs).
But if you want to have more fine grain control over the background of the Button, I’d suggest rebuilding it as the one in Compose is more opinionated based on the Material Design spec
b
Previous it was used on a color
Copy code
<item name="styleButtonActionPrimaryCaution">@style/Button.Action.Primary.Caution</item>
Copy code
<style name="Button.Action.Primary.Caution">
<item name="backgroundTint">@color/selector_color_caution</item>
But in compose a Button only has a
backgroundColor
which has a alpha=1.00 So I only could set a tranparency myself to the background color, but thats probably not the right solution
c
I think that solution is fine. Especially if you wrap this Button in your own Composable, e.g. AppButton, so then it’s reusable
That would be a thematic way of using tint for Buttons across your app