I would like to know if there some way to specify to Jetpack Compose plugin to remove default elevation from Image component, or the only wy is rebuild the image asset.
I have this:
Image(
painter = painterResource(id = if(sessionToken.isNotEmpty()) R.drawable.ic_disa_logo else R.drawable.ic_cepsa_logo),
contentDescription = "login_logo",
modifier = Modifier
.align(CenterHorizontally)
.fillMaxWidth()
Which show like this
As you can check the image have a elevatioon which I'm not adding to the component, so Should I recreate the asset, or is there some way to remove it.
Thanks in advance !
[EDIT]
As the suggestion I try to use a custom shape to hide the border of the image make an implementation of the solution like this:
val offset = with(LocalDensity.current){
4.dp.toPx()
}
val customCircleShape = GenericShape{ size: Size, layoutDirection: LayoutDirection ->
addOval(
Rect(
offset = Offset(
offset, offset
),
size = Size(
width = size.width - 2 * offset,
height = size.height - 2 * offset
)
)
)
}
Column(
verticalArrangement = Arrangement.Top,
modifier = Modifier
.clip(customCircleShape)
.shadow(4.dp, CircleShape)
.size(60.dp)
.background(Color.White)
) {
Image(
painter = painterResource(id = if (sessionToken.isNotEmpty()) R.drawable.ic_disa_logo else R.drawable.ic_cepsa_logo),
contentDescription = "login_logo",
modifier = Modifier
.align(Alignment.CenterHorizontally)
.fillMaxWidth()
.fillMaxHeight(0.25f)
.border(BorderStroke(2.dp, Color.White), CircleShape)
.background(Color.White)
)
}
But the border is still showing as the firts picture I added it
What Am I missing here?
[EDIT]
Doesn't matter how big a do the circle which supose to hide the shadow, don't do it.
I add the picture i'm using as reference.
[SOLUTION]
I make works doing this:
val offset = with(LocalDensity.current){
8.dp.toPx()
}
val customCircleShape = GenericShape { size: Size, layoutDirection: LayoutDirection ->
addOval(
Rect(
offset = Offset(
offset, offset
),
size = Size(
width = size.width - 2 * offset,
height = size.height - 2 * offset
)
)
)
}
Image(
painter = painterResource(id = if(sessionToken.isNotEmpty()) R.drawable.ic_disa_logo else R.drawable.ic_cepsa_logo),
contentDescription = "login_logo",
contentScale = ContentScale.FillBounds,
modifier = Modifier
.align(CenterHorizontally)
.padding(10.dp)
.background(Color.White)
.clip(customCircleShape)
.size(80.dp),
)