I am adding this dependency in Jetpack Compose. I have implemented TopAppBar in Scaffold. There is an Image in my Top App Bar. I gave it a size that is managed by the top app bar. But when I added this dependency then it changed my Image Size and it increased the Top App Bar Height. This is my Code
@OptIn(ExperimentalMaterial3Api::class)
@composable
fun SellerTopBar(actions: @composable RowScope.() -> Unit, onDrawerIconClick: (Boolean) -> Unit) {
var drawerIconStatus by remember { mutableStateOf(false) }
TopAppBar(
title = {
Row(
verticalAlignment = Alignment.CenterVertically
) {
Icon(
imageVector = Icons.Default.Menu,
contentDescription = null,
tint = Color.White,
modifier = Modifier
.padding(end = 20.dp)
.clickable {
onDrawerIconClick(!drawerIconStatus)
})
Image(
painter = painterResource(R.drawable.aajjologoo),
contentDescription = null,
modifier = Modifier.onGloballyPositioned { coordinates ->
val size: IntSize = coordinates.size
Log.d("TopAppBarImageSize", "Width: ${size.width}, Height: ${size.height}")
}.size(100.dp)
)
}
},
colors = TopAppBarDefaults.topAppBarColors().copy(
containerColor = colorResource(R.color.colorPrimary),
scrolledContainerColor = colorResource(R.color.colorPrimary),
navigationIconContentColor = colorResource(R.color.colorPrimary),
titleContentColor = colorResource(R.color.black),
actionIconContentColor = colorResource(R.color.colorPrimary)
),
actions = actions,
)
}
I am also observing the height and width of the Image before and after adding the dependency.
Before adding, Dimensions are - Width: 263, Height: 168
After adding, Dimensions are - Width: 263, Height: 263
I am using the following dependencies
// Jetpack libraries
implementation("androidx.hilt:hilt-navigation-compose:1.2.0")
implementation("androidx.compose.material3:material3")
implementation("androidx.activity:activity-compose:1.10.1")
implementation(platform("androidx.compose:compose-bom:2025.06.00"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling")
implementation("androidx.compose.ui:ui-tooling-preview")
debugImplementation("androidx.compose.ui:ui-test-manifest")
implementation("com.google.accompanist:accompanist-systemuicontroller:0.30.1")
I am adding this dependency in Jetpack Compose. I have implemented TopAppBar in Scaffold. There is an Image in my Top App Bar. I gave it a size that is managed by the top app bar. But when I added this dependency then it changed my Image Size and it increased the Top App Bar Height. This is my Code
@OptIn(ExperimentalMaterial3Api::class)
@composable
fun SellerTopBar(actions: @composable RowScope.() -> Unit, onDrawerIconClick: (Boolean) -> Unit) {
var drawerIconStatus by remember { mutableStateOf(false) }
TopAppBar(
title = {
Row(
verticalAlignment = Alignment.CenterVertically
) {
Icon(
imageVector = Icons.Default.Menu,
contentDescription = null,
tint = Color.White,
modifier = Modifier
.padding(end = 20.dp)
.clickable {
onDrawerIconClick(!drawerIconStatus)
})
Image(
painter = painterResource(R.drawable.aajjologoo),
contentDescription = null,
modifier = Modifier.onGloballyPositioned { coordinates ->
val size: IntSize = coordinates.size
Log.d("TopAppBarImageSize", "Width: ${size.width}, Height: ${size.height}")
}.size(100.dp)
)
}
},
colors = TopAppBarDefaults.topAppBarColors().copy(
containerColor = colorResource(R.color.colorPrimary),
scrolledContainerColor = colorResource(R.color.colorPrimary),
navigationIconContentColor = colorResource(R.color.colorPrimary),
titleContentColor = colorResource(R.color.black),
actionIconContentColor = colorResource(R.color.colorPrimary)
),
actions = actions,
)
}
I am also observing the height and width of the Image before and after adding the dependency.
Before adding, Dimensions are - Width: 263, Height: 168
After adding, Dimensions are - Width: 263, Height: 263
I am using the following dependencies
// Jetpack libraries
implementation("androidx.hilt:hilt-navigation-compose:1.2.0")
implementation("androidx.compose.material3:material3")
implementation("androidx.activity:activity-compose:1.10.1")
implementation(platform("androidx.compose:compose-bom:2025.06.00"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling")
implementation("androidx.compose.ui:ui-tooling-preview")
debugImplementation("androidx.compose.ui:ui-test-manifest")
implementation("com.google.accompanist:accompanist-systemuicontroller:0.30.1")