Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

listview - How to implement the same scrollable menu in the Wearable's launcher?

enter image description here

I'm trying to create a scrollable menu like the one in the picture I saw some similar posts or questions but I haven't been able to achieve any result. The curved scrollable menu that is the Wearable's launcher looks like the one in the picture so how do I implement the same thing but with my app? What do I need to do?

My app basically has a settings Activity that contains: tool number, mode, time, flow rate

think of them as categories, each one of them has a group of radio buttons, what I want is to place the icons for each category in the same manner as in the picture, that way the user can scroll through them easily and navigate between them.

This is my code so far I've been following the code that was in this answer:

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);
    }

}

the code was from here: How to create Circular view on android wear?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...