Jetpack 组合 LazyColumn+Coil-Compose 不起作用

wup*_*pan 3 android-jetpack-compose

Jetpack 撰写项目

\n

我使用 Coil-Compose RememberImagePainter

\n

依赖项{

\n
implementation \'io.coil-kt:coil-compose:1.4.0\'\n
Run Code Online (Sandbox Code Playgroud)\n

}

\n
class MainActivity : ComponentActivity() {\n    override fun onCreate(savedInstanceState: Bundle?) {\n        super.onCreate(savedInstanceState)\n        setContent {\n            ApplicationTheme {\n                Surface(color = MaterialTheme.colors.background) {\n                    Image(\n                        painter = rememberImagePainter("https://api.dujin.org/bing/1366.php"),\n                        contentDescription = null\n                    )\n                }\n            }\n        }\n    }\n}\n
Run Code Online (Sandbox Code Playgroud)\n

在此输入图像描述

\n

添加 LazyColumn 不起作用

\n
\xe2\x80\xa6\xe2\x80\xa6\xe2\x80\xa6\xe2\x80\xa6\nimport coil.compose.rememberImagePainter\n\xe2\x80\xa6\xe2\x80\xa6\xe2\x80\xa6\xe2\x80\xa6\n\nclass MainActivity : ComponentActivity() {\n    override fun onCreate(savedInstanceState: Bundle?) {\n        super.onCreate(savedInstanceState)\n        setContent {\n            ApplicationTheme {\n                Surface(color = MaterialTheme.colors.background) {\n+                   LazyColumn {\n+                       items(10) {\n                            Text(text = "test")\n                            // doesn\'t work\n                            Image(\n                                painter = rememberImagePainter("https://api.dujin.org/bing/1366.php"),\n                                contentDescription = null\n                            )\n+                       }\n+                   }\n                }\n            }\n        }\n    }\n}\n
Run Code Online (Sandbox Code Playgroud)\n

在此输入图像描述

\n

请帮我

\n

Ysh*_*shh 5

在LazyColumn或者LazyRow中本地资源没有问题,但是网络图片就需要指定宽度和高度

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            ApplicationTheme {
                Surface(color = MaterialTheme.colors.background) {
                   LazyColumn {
                       items(10) {
                            Text(text = "test")
                            // doesn't work
                            Image(
                                painter = rememberImagePainter("https://api.dujin.org/bing/1366.php"),
                                contentDescription = null,
                                Modifier.fillMaxSize().height(300.dp)
                            )
                       }
                   }
                }
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)