- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Jetpack 组合项目
我用的是Coil-Compose rememberImagePainter
依赖关系{
implementation 'io.coil-kt:coil-compose:1.4.0'
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
ApplicationTheme {
Surface(color = MaterialTheme.colors.background) {
Image(
painter = rememberImagePainter("https://api.dujin.org/bing/1366.php"),
contentDescription = null
)
}
}
}
}
}
添加 LazyColumn 不起作用
…………
import coil.compose.rememberImagePainter
…………
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
)
+ }
+ }
}
}
}
}
}
请帮帮我
最佳答案
在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)
)
}
}
}
}
}
}
}
关于android-jetpack-compose - Jetpack 撰写 LazyColumn + Coil-Compose 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70764690/
根据 Coil 的文档,我不需要为我的图像做任何配置以适应 fit()。问题是 ImageView 没有正确加载: 这是我对带有 Picasso 的 ImageView 的配置: picasso.lo
我想从 URL 加载位图,然后使用调色板 API 从中获取一些颜色。 在文档页面上,我找不到直接获取位图的代码! 谁能帮我吗? 最佳答案 您可以使用 target方法并将drawable转换为bitm
我试图显示图库中的图像(如果用户选择了任何内容),或者显示可绘制资源中图像文件中的图像作为默认图像,但这是不起作用的。我正在使用 Coil 进行 Compose 并添加了依赖项。这是代码: class
我想将缓存中保存的图像加载到 Image Jetpack Compose 使用 Coil。我在 stackoverflow 中进行了搜索,但所有建议的方法都是加载 web url。我知道可以将图像文件
Jetpack 组合项目 我用的是Coil-Compose rememberImagePainter 依赖关系{ implementation 'io.coil-kt:coil-compose:1.4
我正在使用最新版本的 Coil: 实现(“io.coil-kt:coil-compose:2.0.0-rc01”) 我想将条形码标签图像加载到我的 Jetpack Compose 文件中,如下所示:
Jetpack 组合项目 我用的是Coil-Compose rememberImagePainter 依赖关系{ implementation 'io.coil-kt:coil-compose:1.4
我正在使用最新版本的 Coil: 实现(“io.coil-kt:coil-compose:2.0.0-rc01”) 我想将条形码标签图像加载到我的 Jetpack Compose 文件中,如下所示:
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题吗? 更新问题,以便 editing this post 提供事实和引用来回答它. 关闭6年前。 社区审核了是否重新打
我是一名优秀的程序员,十分优秀!