Giter VIP home page Giter VIP logo

luckywheel_android's Introduction

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.

What's new in 0.3.0

  • Fix the image rotation issue

Sample

Lucky wheel.

Overview

The LuckyWheel shows a wheel which can spin, and a marker that indicates the selected item in the wheel. Items may be customized with text, image, or a color.

The wheel starts off stationary. Calling the setTarget() method with an integer parameter will set the wheel to spin to that section when the user taps the wheel in the UI. Calling rotateWheelTo() with an integer parameter will cause the wheel to spin to that section immediately.

The wheel spins for a few seconds, then fires the setLuckyWheelReachTheTarget callback to notify the application it has stopped moving.

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 {
  	implementation 'com.github.mmoamenn:LuckyWheel_Android:0.3.0'
  }

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

Change item image padding

LuckyWheel:image_padding

Kotlin

Functions to use after reference the Lucky wheel

  • Create wheel sections
val wheelItems: MutableList<WheelItem> = ArrayList()

wheelItems.add(WheelItem(Color.LTGRAY,
BitmapFactory.decodeResource(resources, R.drawable.ic_action_name),
"text 1"))

wheelItems.add(WheelItem(Color.BLUE,
BitmapFactory.decodeResource(resources, R.drawable.ic_action_name),
"text 2"))

wheelItems.add(WheelItem(Color.BLACK,
BitmapFactory.decodeResource(resources, R.drawable.ic_action_name),
"text 3"))

wheelItems.add(WheelItem(Color.GRAY,
BitmapFactory.decodeResource(resources, R.drawable.ic_action_name)
,"text 4"))

wheelItems.add(WheelItem(Color.RED,
BitmapFactory.decodeResource(resources, R.drawable.ic_action_name),
"text 5"))

wheelItems.add(WheelItem(Color.BLACK,
BitmapFactory.decodeResource(resources, R.drawable.ic_action_name),
"text 6"))
  • 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
 lwv.setLuckyWheelReachTheTarget {
 
 }

Note

Last version before support AndroidX com.github.mmoamenn:LuckyWheel_Android:0.1.2

luckywheel_android's People

Contributors

mmoamenn avatar mflisar avatar omarhassanicon avatar mikeblas avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.