Skip to content

Commit 685c122

Browse files
authored
Use ViewGroup.MarginLayoutParams instead of FrameLayout (#923)
1 parent b22a0bf commit 685c122

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

balloon-compose/src/main/kotlin/com/skydoves/balloon/compose/BalloonModifier.kt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import androidx.compose.ui.semantics.semantics
4040
import androidx.compose.ui.unit.Constraints
4141
import androidx.compose.ui.unit.IntSize
4242
import androidx.compose.ui.unit.dp
43-
import androidx.core.view.updateLayoutParams
4443
import androidx.lifecycle.compose.LocalLifecycleOwner
4544
import androidx.lifecycle.setViewTreeLifecycleOwner
4645
import androidx.lifecycle.setViewTreeViewModelStoreOwner
@@ -293,12 +292,12 @@ public fun Modifier.balloon(
293292
val position = coordinates.positionInWindow()
294293
val size = coordinates.size
295294

296-
// Update the anchor view's position and size in the parent view
297-
anchorView.updateLayoutParams<FrameLayout.LayoutParams> {
298-
width = size.width
299-
height = size.height
300-
leftMargin = position.x.toInt()
301-
topMargin = position.y.toInt()
295+
(anchorView.layoutParams as? ViewGroup.MarginLayoutParams)?.let { params ->
296+
params.width = size.width
297+
params.height = size.height
298+
params.leftMargin = position.x.toInt()
299+
params.topMargin = position.y.toInt()
300+
anchorView.layoutParams = params
302301
}
303302
}
304303
}

0 commit comments

Comments
 (0)