【问题标题】:How to Create a curved scrollbar in android wear 2.0?如何在 android wear 2.0 中创建弯曲滚动条?
【发布时间】:2017-08-06 01:21:13
【问题描述】:

我正在使用 Wea​​rableRecyclerView 创建一个弯曲的布局,但默认滚动条仍然是垂直的。有没有办法像 android wear 2.0 启动器一样创建一个弯曲的滚动条?

【问题讨论】:

    标签: android wear-os


    【解决方案1】:

    实际上,对于任何占据整个屏幕的可滚动视图,滚动条都是圆形的。这是 Wear 2.0 的框架功能。

    如果滚动条仍然是垂直的,请确保您的视图确实填满了整个屏幕 - 将其设置为 match_parent 并作为顶级根视图。

    【讨论】:

    • 这对我有用,视图不需要是根视图,但需要填充整个视口(我设置的边距顶部会破坏滚动)。可笑的是,这在任何地方都没有记录
    【解决方案2】:

    使用 boxinsetlayout

    // android.support.wearable.view.BoxInsetLayout

    app:layout_box="left|bottom|right"

    ...您的列表视图和其他内容

    android.support.wearable.view.BoxInsetLayout>

    如果您使用的是 wearableRecyclerView 做CircularChildLayoutManager mChildLayoutManager = new CircularChildLayoutManager(mContext); 并将其设置为您的回收站视图的布局管理器。

    mRecyclerView.setLayoutManager(mChildLayoutManager);
    

    这可能会为你解决。

    【讨论】:

    • 我已经用过 BoxInsetLayout ,添加 app:layout_box="left|bottom|right" 还是不行。
    • 考虑正确格式化您的答案,使用代码块或反引号以提高可读性
    • 我是新手...所以没关系...我会相应改进...感谢您的回复。
    【解决方案3】:

    API 已重命名为 CurvedChildLayoutManager

    所以用

    val layoutManager = CurvedChildLayoutManager(this)
    recyclerView.layoutManager = layoutManager
    

    PS:对于主题问题,您不需要app:layout_box,只需在您的WearableRecyclerView 上使用android:scrollbars="vertical"

    https://developer.android.com/reference/android/support/wearable/view/CurvedChildLayoutManager.html

    【讨论】:

    • 我无法解析 CurvedChildLayoutManager 类,你知道为什么吗?我的依赖是 dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.google.android.support:wearable:2.0.0' compile 'com.google.android.gms: play-services-wearable:10.2.1' 提供 'com.google.android.wearable:wearable:2.0.0' }
    • @fangjack 试试 2.0.1
    • 我改成 2.0.1,CurvedChildLayoutManager 被导入了。但是使用 CurvedChildLayoutManager 并没有像我预期的那样工作,滚动条仍然是垂直的,而不是弯曲的。
    • 我也一样,滚动条还是垂直的!
    • 不幸的是,这个答案已被弃用
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-07-23
    • 1970-01-01
    • 2018-04-26
    • 1970-01-01
    • 1970-01-01
    • 2017-10-31
    • 1970-01-01
    相关资源
    最近更新 更多