• Stars
    star
    164
  • Rank 230,032 (Top 5 %)
  • Language
    Java
  • Created about 8 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This is an other option to implement custom view like lucky wheel

Screenshot

Example Image

Usage

Include LuckyWheel widget in your layout:

<rubikstudio.library.LuckyWheelView
    android:layout_centerInParent="true"
    app:lkwBackgroundColor="#FF9800"
    app:lkwTopTextColor="#263238"
    app:lkwCenterImage="@drawable/wheel2"
    app:lkwCursor="@drawable/ic_cursor"
    android:id="@+id/luckyWheel"
    android:layout_width="300dp"
    android:layout_height="300dp" />

You also have the option to add the following parameters:

...
        app:lkwEdgeColor="#e2e5eb"
        app:lkwEdgeWidth="25"
        app:lkwTopTextPadding="10dp"
        app:lkwTopTextSize="12sp"
        app:lkwSecondaryTextSize="25sp" />

And in your code :

LuckyWheelView luckyWheelView = (LuckyWheelView) findViewById(R.id.luckyWheel);
List<LuckyItem> data = new ArrayList<>();
for (int i=0; i<12; i++) {
    LuckyItem luckyItem = new LuckyItem();
    luckyItem1.topText = "Item " + i;
    luckyItem1.icon = R.drawable.test;
    luckyItem1.color = 0xffFFF3E0;
    data.add(luckyItem);
}

luckyWheelView.setData(data);
luckyWheelView.setRound(10);

// start
luckyWheelView.startLuckyWheelWithTargetIndex(index);

// listener after finish lucky wheel
luckyWheelView.setLuckyRoundItemSelectedListener(new LuckyWheelView.LuckyRoundItemSelectedListener() {
    @Override
    public void LuckyRoundItemSelected(int index) {
        // do something with index
    }
});

#Custom LuckyWheel

You can setting these properties of the lucky wheel view with xml :

    app:lkwBackgroundColor="#FF9800"
    app:lkwTopTextColor="#263238"
    app:lkwCenterImage="@drawable/wheel2"
    app:lkwCursor="@drawable/ic_cursor"

Or with code like:

    luckyWheelView.setLuckyWheelBackgrouldColor(0xff0000ff);
    luckyWheelView.setLuckyWheelTextColor(0xffcc0000);
    luckyWheelView.setLuckyWheelCenterImage(getResources().getDrawable(R.drawable.icon));
    luckyWheelView.setLuckyWheelCursorImage(R.drawable.ic_cursor);

#Sample Check out the sample application to see it in action!

Contributing

Contributions welcome via Github pull requests.