Lucky Wheel

Additional

Language
Java
Version
0.1.2 (Jun 16, 2019)
Created
Apr 22, 2017
Updated
Jun 16, 2019
Owner
Mohamed Mo'men (mmoamenn)
Contributors
MFlisar
Mohamed Mo'men (mmoamenn)
2
Activity
Badge
Generate
Download
Source code
APK file

Advertising

LuckyWheel Android

Android custom component that displays a lucky wheel. it features easy customize of colors , text and addition of items and it's very trivial to integrate in your application.

Sample

.

Installing

Add it in your root build.gradle at the end of repositories:

  allprojects {
   repositories {
    ...
    maven { url 'https://jitpack.io' }
   }
  }

Step 2. Add the dependency

dependencies {
   compile 'com.github.mmoamenn:LuckyWheel_Android:0.1.2'
  }

XML

<com.bluehomestudio.luckywheel.LuckyWheel
        android:id="@+id/lwv"
        android:layout_width="250dp"
        android:layout_height="250dp"
        android:layout_centerInParent="true"
        LuckyWheel:background_color="@color/colorPrimary" />

You must use the following properties in your XML

Choose the background color

LuckyWheel:background_color

Choose wheel image arrow

LuckyWheel:arrow_image

JAVA

Functions to use after reference the Lucky wheel

  • Create wheel sections
List<WheelItem> wheelItems = new ArrayList<>();
wheelItems.add(new WheelItem(Color.LTGRAY, BitmapFactory.decodeResource(getResources(),
                R.drawable.ic_action_name) , "text 1"));
                
wheelItems.add(new WheelItem(Color.BLUE, BitmapFactory.decodeResource(getResources(),
                R.drawable.ic_action_name) , "text 2"));
                
wheelItems.add(new WheelItem(Color.BLACK, BitmapFactory.decodeResource(getResources(),
                R.drawable.ic_action_name) , "text 3"));
                
wheelItems.add(new WheelItem(Color.GRAY, BitmapFactory.decodeResource(getResources(),
                R.drawable.ic_action_name) , "text 4"));`
  • Add sections to wheel
 addWheelItems(wheelItems);
  • Rotate by touch -- set target before user touch wheel
 setTarget(3);
  • Rotate to section -- not need if you will use touch
 rotateWheelTo(2);
  • On target reach listener
 setLuckyWheelReachTheTarget(new OnLuckyWheelReachTheTarget() {
            
            @Override
            public void onReachTarget() {
            
                // target reached do operation her    
            
            }
        });