Tha*_*s M 8 android kotlin android-jetpack android-jetpack-compose composable
在我的 Android 应用程序中,我使用 Jetpack Compose 作为 UI。
在屏幕中,我使用从 URL 下载的 Lottie 文件来渲染图像。Lottie 图像文件的渲染如下:
@Composable
private fun Image(assetUrl: String) {
val composition by rememberLottieComposition(LottieCompositionSpec.Url(assetUrl))
val progress by animateLottieCompositionAsState(composition, iterations = LottieConstants.IterateForever)
LottieAnimation(
composition = composition,
progress = { progress }
)
}
Run Code Online (Sandbox Code Playgroud)
我想提供一个预览可组合方法,该方法也将呈现上述Image可组合项。理想情况下,我希望能够做这样的事情:
@Preview
@Composable
private fun ScreenPreview(){
Theme {
Surface {
Screen(assetUrl = /* Some URL */)
}
}
}
Run Code Online (Sandbox Code Playgroud)
例如,屏幕将是一些包含可组合项的可Image组合项:
@Composable
fun Screen(assetUrl: String){
Image(
assetUrl = assetUrl
)
}
Run Code Online (Sandbox Code Playgroud)
问题:
| 归档时间: |
|
| 查看次数: |
601 次 |
| 最近记录: |