Useful Modifiers In Jetpack Compose Part — II

Jayant Kumar🇮🇳
2 min readOct 27, 2023
Photo by Harry Grout on Unsplash

If you haven’t read the first article on it , READ IT FROM HERE .

1). offset Modifier

Through offset modifier , we can change the x and y position of any composable functions.

@Composable
fun OffsetModifier(
modifier: Modifier = Modifier
) {
Box(
modifier = modifier
.padding(50.dp)
.background(Color.LightGray)
.fillMaxWidth()
.height(100.dp),
contentAlignment = Alignment.TopCenter
) {
Text(
text = stringResource(R.string.offset_content),
modifier = Modifier.offset(x = 0.dp, y = -(15.dp)),
style = TextStyle(
color = Color.Black,
fontSize = 20.sp
)
)
}
}

As you can see above in the offset modifier , we passed x to 0.dp and y to -15.dp. So that it change the position to upside. if we pass 15.dp then it will move to downside.

Same for x — if + , it will move to the right side , otherwise left side.

2). combinedClickable Modifier

--

--

Jayant Kumar🇮🇳
Jayant Kumar🇮🇳

Written by Jayant Kumar🇮🇳

Hello My name is Jayant Kumar, I am a software Engineer , specialist in Mobile Development (Android , IOS , Flutter , React Native and Ionic) from India 🇮🇳

No responses yet