微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在可穿戴设备的启动器中实现相同的可滚动菜单?

如何解决如何在可穿戴设备的启动器中实现相同的可滚动菜单?

enter image description here

我正在尝试创建一个类似于图片中的可滚动菜单我看到了一些类似的帖子或问题,但我一直无法取得任何结果。作为可穿戴设备启动器的弯曲可滚动菜单看起来像图片中的那个,那么我如何实现同样的事情,但我的应用程序呢?我需要做什么?

我的应用基本上有一个设置Activity,包含:工具编号、模式、时间、流量

将它们视为类别,每个类别都有一组单选按钮,我想要的是按照与图片中相同的方式放置每个类别的图标,这样用户就可以轻松地滚动它们并在它们之间导航。

到目前为止,这是我的代码,我一直在关注此答案中的代码

private void onLayoutInflated()
{
    CustomScrollingLayoutCallback customScrollingLayoutCallback = new CustomScrollingLayoutCallback();
    wearableRecyclerView.setLayoutManager(new Wearablelinearlayoutmanager(circular_menu_external.this,customScrollingLayoutCallback));
    wearableRecyclerView.setEdgeItemsCenteringEnabled(true);

}

private class CustomScrollingLayoutCallback extends Wearablelinearlayoutmanager.LayoutCallback {

    private static final float MAX_ICON_PROGRESS = 2F;

    @Override
    public void onLayoutFinished(View child,RecyclerView parent) {

        float centerOffset = ((float) child.getHeight() / 2.0f) / (float) parent.getHeight();
        float yRelativetoCenterOffset = (child.getY() / parent.getHeight()) + centerOffset;

        float progresstoCenter = (float) Math.sin(yRelativetoCenterOffset * Math.PI);

        float mProgresstoCenter = Math.abs(0.5f - yRelativetoCenterOffset);

        mProgresstoCenter = Math.min(mProgresstoCenter,MAX_ICON_PROGRESS);

        child.setScaleX(1 - mProgresstoCenter);
        child.setScaleY(1 - mProgresstoCenter);
        child.setX(+(1 - progresstoCenter) * 100);
    }

}

代码来自这里:How to create Circular view on android wear?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?