You can learn about jetpack compose with simple examples. Our blog - https://www.jetpackcompose.net/
Text(
text = "Text with Italic text",
style = TextStyle(fontSize = 20.sp, fontStyle = FontStyle.Italic)
)
@Composable
fun ButtonWithIcon() {
Button(onClick = {}) {
Image(
painterResource(id = R.drawable.ic_cart),
contentDescription ="Cart button icon",
modifier = Modifier.size(20.dp))
Text(text = "Add to cart",Modifier.padding(start = 10.dp))
}
}
@Composable
fun CircleImageView() {
Image(
painter = painterResource(R.drawable.andy_rubin),
contentDescription = "Circle Image",
contentScale = ContentScale.Crop,
modifier = Modifier
.size(128.dp)
.clip(CircleShape) // clip to the circle shape
.border(5.dp, Color.Gray, CircleShape)//optional
)
}
@Composable fun TextFieldWithIcons() { var text by remember { mutableStateOf(TextFieldValue("")) } return OutlinedTextField( value = text, leadingIcon = { Icon(imageVector = Icons.Default.Email, contentDescription = "emailIcon") }, //trailingIcon = { Icon(imageVector = Icons.Default.Add, contentDescription = null) }, onValueChange = { text = it }, label = { Text(text = "Email address") }, placeholder = { Text(text = "Enter your e-mail") }, ) }
@Composable
fun ScaffoldWithBottomMenu() {
Scaffold(bottomBar = {BottomBar()}
) {
//content area
Box(modifier = Modifier
.background(Color(0xff546e7a))
.fillMaxSize())
}
}
@Composable
private fun AnimateAsFloatContent() {
var isRotated by rememberSaveable { mutableStateOf(false) }
val rotationAngle by animateFloatAsState(
targetValue = if (isRotated) 360F else 0f,
animationSpec = tween(durationMillis = 2500)
)
Column(horizontalAlignment = Alignment.CenterHorizontally) {
Image(
painter = painterResource(R.drawable.fan),
contentDescription = "fan",
modifier = Modifier
.rotate(rotationAngle)
.size(150.dp)
)
Button(
onClick = { isRotated = !isRotated },
modifier = Modifier
.padding(top = 50.dp)
.width(200.dp)
) {
Text(text = "Rotate Fan")
}
}
}