Repository navigation
Replies: 1 comment
|
The unnatural shadow is a known limitation of Android renders elevation shadows at the window boundary, not the view boundary. When a This is different from Material Design elevation (e.g. Practical fix — use a custom background drawable instead of // res/drawable/balloon_shadow_bg.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/your_balloon_color" />
<corners android:radius="4dp" />
<stroke android:width="1dp" android:color="#1A000000" /> <!-- subtle border as shadow hint -->
</shape>val builder = rememberBalloonBuilder {
// Remove setElevation() — it won't give all-around shadow in PopupWindow
setBackgroundDrawableResource(R.drawable.balloon_shadow_bg)
setPadding(8)
setMarginHorizontal(16)
setMarginTop(8) // breathing room so arrow isn't clipped
setCornerRadius(4f)
setBalloonAnimation(OVERSHOOT)
// rest of your config
}For a more realistic drop shadow on all sides, consider wrapping your Balloon(
builder = builder,
balloonContent = {
Card(
elevation = CardDefaults.cardElevation(defaultElevation = 8.dp),
shape = RoundedCornerShape(4.dp)
) {
Text(
text = text,
color = MaterialTheme.colorScheme.onPrimary,
modifier = Modifier.padding(8.dp)
)
}
}
) { balloonWindow -> ... }The |
Uh oh!
There was an error while loading. Please reload this page.
Hello, I'm using
setElevation()andsetArrowElevation()to add a shadow for the balloon, but it looks unnature, you can see from the screenshot.Hope it can be looks like a real shadow, refer the MaterialDesign.
Or maybe I misunderstood how to set it ?
here is my code of the Balloon view,
and the sample View to call the Balloon composable,
All reactions