So I am going over a few YouTube tutorials on YouT...
# compose
c
So I am going over a few YouTube tutorials on YouTube. The issue is that Compose is in Alpha and changing. Where can I find what is the most up to date info on component properties? I noticed that on
OutlinedButton
we can no longer set
backgroundColor
or
contentColor
and I am no sure of how to do this. I also noticed that
verticalGravity
is gone, but it has been replaced with
verticalAlignment
. While that was slightly obvious using auto-completion, I can't find the color properties. Or how I might navigate how to find these changed properties in the future. It seems
colors
is something I have to look at, but I am not sure how to execute this in code yet
You can see the two commented out lines below that I need to modify.
Copy code
fun AppBar() {
    Surface(color = MaterialTheme.colors.primary) {
        TopAppBar(modifier = Modifier.fillMaxWidth()) {
            Row(
                modifier = Modifier
                    .fillMaxWidth().fillMaxHeight()
                    .padding(8.dp),
                verticalAlignment = Alignment.CenterVertically,
                horizontalArrangement = Arrangement.SpaceBetween
            ) {
                Icon(asset = Icons.Filled.ArrowBack)
                OutlinedButton(
                    onClick = {},
//                    backgroundColor = Color.Transparent,
                    shape = CircleShape,
//                    contentColor = Color.White
                border = BorderStroke(1.dp, color = Color.White)
                ) {
                    Text(text = "Follow")
                }
            }
        }
    }
s
You can keep a watch on release notes or check the docs for API changes. Add this param to your
OutlinedButton
to change its colors:
Copy code
colors = ButtonConstants.defaultOutlinedButtonColors(
    backgroundColor = Color.Transparent,
    contentColor = Color.White
)
👍 1
c
Thanks. I am also trying to find how to do things via auto-complete and Go To Source. I thought that might be possible, but it looked like a hack and not the standard way. I noticed that
BorderStroke
uses a data class that is really easy to setup, where as
ButtonColors
uses an interface instead and you need to search for the correct
defaultX
function to call
It appears like
colors = ButtonConstants.defaultButtonColors(...)
works just as well. Is there a reason not to use that when just setting these basic properties?
l
It appears like 
colors = ButtonConstants.defaultButtonColors(...)
  works just as well. Is there a reason not to use that when just setting these basic properties?
That's the default for a
Button
, not an
OutlinedButton
- so the colors won't match the styling for the rest of the button
s
Using
defaultButtonColors()
will use different background colors for enabled and disabled states, whereas using
defaultOutlinedButtonColors()
, will use the same background color when enabled or disabled.