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")
    }

请帮帮我. I use this IDE. 个 我正在学习喷气背包作曲,这意味着我完全是喷气背包作曲的初学者.

推荐答案

对于remembermutableStateOf,添加以下导入语句:

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)

Android相关问答推荐

在编写中强制软键盘呈现

如何删除Jetpack Compose中的Textfield底线

我正在创建一个简单的连接四个游戏,我需要一个弹出式窗口当你赢了

在Jetpack Compose中从LazyColumn中删除项目时发生IndexOutOf边界异常

如何使用进度条和返回函数进行API调用,同时在Android上使用Kotlin保持高效?

在androidStudio中,如何使用带有ResolutionStrategy的ResolutionSelector而不是setTargetResolve()?

Android布局渲染问题

Visual Studio 2022,毛伊岛,Android Emulator:无法更改内存量

将输出写入已发布的 Android 应用程序中的日志(log)文件?

当我想使用例如 material3 时,为什么我需要添加对 material 的依赖?底部导航?

如何删除 Jetpack Compose 中按钮的左边框?

通知使用默认语言,屏幕显示多种语言,同时通过 AppCompatDelegate 设置应用程序语言

在 Material 3 TopAppBar 代码的哪个位置定义了填充?

在 Jetpack Compose 中重用具有重复代码的列

Jetpack Compose 部分或开放侧边框

如何解决 compose 中material 图标的由于接收器类型不匹配,以下候选者都不适用

更新应用程序是否会取消对应用程序特定文件的权限?

如何在 Kotlin 的片段中制作图像列表?

compose :为什么以记住启动的列表触发方式与快照不同

使用 Android 字符串数组在 Room 中迁移