wup*_*pan 3 android-jetpack-compose
Jetpack 撰写项目
\n我使用 Coil-Compose RememberImagePainter
\n依赖项{
\nimplementation \'io.coil-kt:coil-compose:1.4.0\'\nRun Code Online (Sandbox Code Playgroud)\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 Image(\n painter = rememberImagePainter("https://api.dujin.org/bing/1366.php"),\n contentDescription = null\n )\n }\n }\n }\n }\n}\nRun 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}\nRun Code Online (Sandbox Code Playgroud)\n\n请帮我
\n在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)
| 归档时间: |
|
| 查看次数: |
2001 次 |
| 最近记录: |