GithubHelp home page GithubHelp logo

spinningwheelandroid's Introduction

SpinningWheelAndroid

1

Attributes

  • wheel_colors -> Color value
  • wheel_stroke_color -> Color value
  • wheel_stroke_width -> Dimension value
  • wheel_items -> Array of string
  • wheel_text_size -> Dimension value
  • wheel_text_color -> Color value
  • wheel_arrow_color -> Color value
  • wheel_arrow_width -> Dimension value
  • wheel_arrow_height -> Dimension value

Example

  1. Custom view in xml
<com.adefruandta.spinningwheel.SpinningWheelView
        android:id="@+id/wheel"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        app:wheel_arrow_color="@android:color/black"
        app:wheel_colors="@array/rainbow_dash"
        app:wheel_items="@array/dummy"
        app:wheel_stroke_color="@android:color/black"
        app:wheel_stroke_width="5dp"/>
  1. Custom view in java
public class MainActivity extends AppCompatActivity implements SpinningWheelView.OnRotationListener<String> {

        ...
        
        @Override
        protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                
                ...

                SpinningWheelView wheelView = (SpinningWheelView) findViewById(R.id.wheel);

                // Can be array string or list of object
                wheelView.setItems(R.array.dummy);
                
                // Set listener for rotation event
                wheelView.setOnRotationListener(new OnRotationListener<String>() {
                        // Call once when start rotation
                        @Override
                        public void onRotation() {
                        Log.d("XXXX", "On Rotation");
                        }

                        // Call once when stop rotation
                        @Override
                        public void onStopRotation(String item) {
                        Log.d("XXXX", "On Rotation");
                        }
                });
                
                // If true: user can rotate by touch
                // If false: user can not rotate by touch
                wheelView.setEnabled(false);
                
                rotate.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        // max angle 50
                        // duration 10 second
                        // every 50 ms rander rotation
                        wheelView.rotate(50, 3000, 50);
                    }
                });
        }

Download

Configure your project-level build.gradle to include the 'android-apt' plugin:

repositories {
    maven {
        url 'https://dl.bintray.com/adef145/maven/'
    }
}

...

dependencies {
    compile 'com.adefruandta.spinningwheel:spinningwheel:0.1.0'
}

Licence

Copyright 2017 Ade Fruandta

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

spinningwheelandroid's People

Contributors

adef145 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.