I'm learning Jetpack Compose and I was trying to customize a display of an image with Modifier methods height and padding. But I got the Problem messages "Unresolved reference: height" and "Unresolved reference: padding".
@Preview
@Composable
fun imageDisplay() {
Column(
modifier = Modifier.padding(16.dp)
) {
Image(
painter = painterResource(R.drawable.photo_1505740420928_5e560c06d30e),
contentDescription = null,
modifier = Modifier
.height(180.dp)
.fillMaxWidth()
.clip(shape = RoundedCornerShape(4.dp)),
contentScale = ContentScale.Crop
)
}
}
padding and height methods highlighted in red
Am I missing something?
Make sure that the package import is correct. Sometimes we accidently import the wrong package for the Modifier function
Use the correct package.
import androidx.compose.ui.Modifier
Everything looks fine. Make sure you're using the newest version of Android Studio, gradle and compose versions.
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.ui:ui-tooling:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.material:material-ripple:$compose_version"
And finally, check if you imported the correct Modifier class.
You must use the one from androidx.compose.ui package.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With