当我将工作管理器库添加到 android studio 并运行该应用程序时,它崩溃并出现以下错误:
E/SQLiteLog: (14) cannot open file at line 37816 of [c255889bd9]
(14) os_unix.c:37816: (13) lstat(/data/user/0/com.example/no_backup/androidx.work.workdb) -
(1) Process m.example : Pid (13632) Uid (11395) Euid (11395) Gid (11395) Egid (11395)
(1) osStat failed "/data/user/0/com.example/no_backup/androidx.work.workdb" due to error (13)
(1) osStat failed "/data/user/0/com.first.academy/no_backup" due to error (13)
(1) Stat of /data/user/0/com.example : st_mode(40700) st_uid(11385) st_gid(11385) st_ino(164253)
(1) Stat of /data/user/0 : st_mode(40771) st_uid(1000) st_gid(1000) st_ino(131074)
(1) Stat of /data/user : st_mode(40711) st_uid(1000) st_gid(1000) st_ino(655366)
(1) Stat of /data …
Run Code Online (Sandbox Code Playgroud) 我想实现这种布局:
在 XML 中,我会在具有 match_parent 属性的相对布局中添加一个图像,然后是一个黑色半透明背景设置为 match_parent 的视图,然后是内容。
在 compose 中,我使这个变得可组合:
@Composable
fun ImageCover(resourceId: Int, alpha: Float = 0.5f, content: @Composable () -> Unit) {
Box(modifier = Modifier.fillMaxSize()) {
Image(
painter = painterResource(id = resourceId),
contentDescription = null,
modifier = Modifier.fillMaxSize(),
contentScale = ContentScale.Crop
)
Surface(
color = Color.Black, modifier = Modifier
.fillMaxSize()
.alpha(alpha)
) {
content()
}
}
}
Run Code Online (Sandbox Code Playgroud)
但问题是 alpha 应用于表面及其内容。所以无论我放什么内容,即使是另一个有背景的表面,也会半透明。例如,在这里,底部的两个句子和两个组件也将是半透明的。
我想实现一个类似于这样的进度条:
在材料的设计文档,它说我需要设置indeterminateAnimationType
来contiguous
实现这一目标,并提供三种颜色。但是当indicatorColor
属性只接受一种颜色时如何提供三种颜色?
当我运行这段代码时,它抛出一个异常说Contiguous indeterminate animation must be used with 3 or more indicator colors
:
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:indeterminate="true"
app:indeterminateAnimationType="contiguous"
app:hideAnimationBehavior="outward"
app:showAnimationBehavior="inward"
app:trackThickness="5dp" />
Run Code Online (Sandbox Code Playgroud) xml android android-progressbar material-design material-components-android