我一直在处理这些问题,请帮助解决这些问题。我想展示一个喷气背包构图的动画绘图
错误-
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
我有这些进口产品-
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
我的代码
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")
}
请帮帮我。我使用这个IDE。我正在学习喷气背包作曲,这意味着我是喷气背包作曲的初学者。
对于remember
和mutableStateOf
,添加以下导入语句:
import androidx.compose.runtime.*
对于animatedVectorResource
,添加androidx.compose.animation:animation-graphics
依赖项并使用
import androidx.compose.animation.graphics.res.animatedVectorResource
import androidx.compose.animation.graphics.vector.AnimatedImageVector
val image = AnimatedImageVector.animatedVectorResource(R.drawable.test)