I'm keep getting this issues please help to fix these. I want to show an animated drawable in jetpack compose.
Error -
e: /myproject/../MainActivity.kt: (42, 17): Unresolved reference: animatedVectorResource
e: /myproject/../MainActivity.kt: (43, 18): Unresolved reference: remember
e: myproject/../MainActivity.kt: (43, 29): Unresolved reference: mutableStateOf
I have these imports -
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.material3.Text
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.Modifier
import com.google.accompanist.systemuicontroller.rememberSystemUiController
import androidx.compose.foundation.layout.Column
import androidx.compose.material.MaterialTheme
import androidx.compose.foundation.Image
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.res.painterResource
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.ui.layout.ContentScale
My Code
val image = animatedVectorResource(R.drawable.test)
var atEnd by remember { mutableStateOf(false) }
Image(painter = image.painterFor(atEnd),contentDescription = "",modifier = Modifier.fillMaxSize(), contentScale = ContentScale.FillBounds)
Column(modifier = Modifier.fillMaxSize()){
Text("Hello")
Text("World")
}
Please help me out. I use this IDE. I'm learning jetpack compose, means I am total beginner in jetpack compose.
CodePudding user response:
For remember
and mutableStateOf
add these import statements:
import androidx.compose.runtime.*
For animatedVectorResource
add the androidx.compose.animation:animation-graphics
dependency and use
import androidx.compose.animation.graphics.res.animatedVectorResource
import androidx.compose.animation.graphics.vector.AnimatedImageVector
val image = AnimatedImageVector.animatedVectorResource(R.drawable.test)