【问题标题】:Wear OS show image with horizontal scrollWear OS 显示带有水平滚动的图像
【发布时间】:2022-10-04 17:25:44
【问题描述】:

我需要在 Galaxy 5 手表上显示这样的长图像

我在哪里可以找到这项工作的代码示例?或者我可以使用哪个组件?

    标签: android wear-os wearables


    【解决方案1】:

    您可以在 Compose 中使用水平滚动的 Row。

    Row(
        modifier = Modifier.horizontalScroll(scrollState)
    ) {
            // ...
    }
    

    https://developer.android.com/jetpack/compose/lists

    您可以使用 RSB/Bezel 使其水平滚动

    public fun Modifier.scrollableRow(
        focusRequester: FocusRequester,
        scrollableState: ScrollableState
    ): Modifier = composed {
        val coroutineScope = rememberCoroutineScope()
    
        onPreRotaryScrollEvent {
            coroutineScope.launch {
                // events are vertical, but apply horizontally
                scrollableState.scrollBy(it.verticalScrollPixels)
                scrollableState.animateScrollBy(0f)
            }
            true
        }
            .focusRequester(focusRequester)
            .focusable()
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-04
      • 1970-01-01
      • 2019-03-08
      相关资源
      最近更新 更多