小编eny*_*iaa的帖子

Android Studio矢量资产导入错误 - 不支持的标记

我一直在使用新的gradle插件测试Andorid Studio - 1.4.0-beta3.

我一直在尝试导入我自己的矢量资产,在Inkscape中制作.但是我不断收到导入错误.错误消息包含svg中许多不支持的标记.

In mm_card.svg:
ERROR@ line 54 <defs> is not supported
ERROR@ line 56 <linearGradient> is not supported
ERROR@ line 58 <stop> is not supported
ERROR@ line 62 <stop> is not supported
ERROR@ line 66 <stop> is not supported
ERROR@ line 70 <stop> is not supported
ERROR@ line 74 <stop> is not supported
ERROR@ line 78 <stop> is not supported
ERROR@ line 83 <linearGradient> is not supported
ERROR@ line 85 <stop> is not supported
ERROR@ line 89 …
Run Code Online (Sandbox Code Playgroud)

svg android vector-graphics android-studio

15
推荐指数
1
解决办法
1万
查看次数

如何在 Jetpack Compose 中将触摸事件分派给父可组合项

我似乎找不到有关 Compose 中触摸处理的太多信息。

在我正在查看的具体情况下,我有一个这样的列表:

@Composable
fun MyListComposable(items: List<Item>) {
    LazyColumn(
        contentPadding = paddingValues(listHorizontalMargin, listVerticalMargin),
    ) {
        // Init items emitted for brevity
    }

}
Run Code Online (Sandbox Code Playgroud)

该列表包含在使用swipeable修饰符的父级中,如下所示。

Card(
    modifier = Modifier.swipeable(
        state = state,
        anchors = mapOf(
            0.dp.value to DrawerState.OFFSCREEN,
            50.dp.value to DrawerState.PEEKING,
            maxHeight.value to DrawerState.EXPANDED,
        ),
        reverseDirection = true,
        thresholds = { _, _ -> FractionalThreshold(0f) },
        orientation = Orientation.Vertical
    ) {
         MyListComposable(items)
}
Run Code Online (Sandbox Code Playgroud)

我的问题是列表吞噬了所有触摸,因此永远不会调用可滑动项。所以我的问题是,有没有办法阻止懒惰的列吞噬触摸?

android android-jetpack-compose

14
推荐指数
0
解决办法
2877
查看次数

使用协程的 Kotlin/Native 多线程

我一直在尝试使用 kotlin 多平台,它非常棒,但线程让我难堪。线程之间的状态冻结在概念上是有意义的,并且在来回传递小对象或原语的简单示例中工作正常,但在现实世界的应用程序中,我无法绕过 InvalidMutabilityException。

从 Android 应用程序中获取以下常见代码片段

class MainViewModel(
    private val objectWhichContainsNetworking: ObjectWhichContainsNetworking
)

    private var coreroutineSupervisor = SupervisorJob()
    private var coroutineScope: CoroutineScope = CoroutineScope(Dispatchers.Main + coreroutineSupervisor)

    private fun loadResults() {
        // Here: Show loading
        coroutineScope.launch {
            try {
                val result = withContext(Dispatchers.Default) { objectWhichContainsNetworking.fetchData() }
                // Here: Hide loading and show results
            } catch (e: Exception) {
                // Here: Hide loading and show error
            }
    }
}
Run Code Online (Sandbox Code Playgroud)

没有什么非常复杂的,但如果在公共代码中使用并从 Kotlin/Native 运行,那么在 MainViewModel 上 pow InvalidMutabilityException。

其原因似乎是传入 withContext 的任何内容都被递归冻结,因为 objectWhichContainsNetworking 是 …

kotlin kotlin-native kotlin-multiplatform kotlin-coroutines

5
推荐指数
1
解决办法
1273
查看次数