Android Wheel Widget

This is a simple widget I created as part of the Aviary Editor SDK for Android. It creates a wheel-like widet which can be scrolled in both directions.
The idea was to replace the default slider widget and use a more “real world” component.
Moreover if you’ll add the VIBRATE permission into your AndroidManifest.xml file you’ll have also haptics feedback while the wheel is scrolling:
[cce]<uses-permission android:name=”android.permission.VIBRATE” />[/cce]

To include the wheel widget in the current layout, you should add in the layout xml this lines:

<it.sephiroth.android.wheel.view.Wheel
android:id=”@+id/wheel”
xmlns:sephiroth=”http://schemas.android.com/apk/res/it.sephiroth.android.wheel”
android:layout_width=”match_parent”
android:layout_height=”match_parent”
sephiroth:numRotations=”6″
sephiroth:ticks=”28″ />

Where numRotations is the max number of rotations the wheel can perform and ticks is the total number of ticks the wheel will display.

Then in your activity you can add a OnScrollListener listener to the wheel widget, in this way:

mWheel = (Wheel) findViewById( R.id.wheel );
mWheel.setOnScrollListener( new OnScrollListener() {

@Override
public void onScrollStarted( Wheel view, float value, int roundValue ) {
}

@Override
public void onScrollFinished( Wheel view, float value, int roundValue ) {
}

@Override
public void onScroll( Wheel view, float value, int roundValue ) {
}
} );

You can download the source at the gihub project page.

Share with...