Skip to content

Instantly share code, notes, and snippets.

@parthdesai1208
Last active February 9, 2022 09:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parthdesai1208/427f5a0b72d23611bcb19a7e94dfa2a5 to your computer and use it in GitHub Desktop.
Save parthdesai1208/427f5a0b72d23611bcb19a7e94dfa2a5 to your computer and use it in GitHub Desktop.
Jetpack Compose
@Preview
@Composable
fun ForSurface() {
Surface(
shape = MaterialTheme.shapes.medium,
elevation = 2.dp,
border = BorderStroke(1.dp, colorResource(id = R.color.black)), //apply border
color = colorResource(id = R.color.teal_200), //apply foreground color
contentColor = colorResource(id = R.color.white), //apply color to all child view
modifier = Modifier
.animateContentSize() // animateContentSize will change the Surface size gradually
.padding(1.dp)
) {
Text(
text = "Hi I am surface compose",
modifier = Modifier.padding(all = 4.dp),
// If the message is expanded, we display all its content
// otherwise we only display the first line
style = MaterialTheme.typography.body2
)
}
}
@parthdesai1208
Copy link
Author

parthdesai1208 commented Feb 9, 2022

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment