Skip to content
Discussion options

You must be logged in to vote

Yes. libpag doesn't ship a Compose-native composable, but its Android views (PAGView / PAGImageView) are regular Views, so you can embed them in Compose with AndroidView. That works fine for transparent animations.

@Composable
fun PagAnimation(
    assetPath: String,
    modifier: Modifier = Modifier,
    repeatCount: Int = 0, // 0 = loop forever
) {
    val context = LocalContext.current
    val pagFile = remember(assetPath) { PAGFile.Load(context.assets, assetPath) }

    AndroidView(
        modifier = modifier,
        factory = { ctx ->
            PAGView(ctx).apply {
                composition = pagFile
                setRepeatCount(repeatCount)
                play()
           …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by CodeJhF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants