I\'m trying to take the android-wheel from http://code.google.com/p/android-wheel/ and make it display horizontally. My first attempt to make this happen came from a suggestion
Did you rotate the appropriate layouts xmls as well? This code sets the background Resources and some of the drawables using xml. I'm betting they're not rotated.
private void initResourcesIfNecessary() {
if (centerDrawable == null) {
centerDrawable = getContext().getResources().getDrawable(R.drawable.wheel_val);
}
if (topShadow == null) {
topShadow = new GradientDrawable(Orientation.TOP_BOTTOM, SHADOWS_COLORS);
}
if (bottomShadow == null) {
bottomShadow = new GradientDrawable(Orientation.BOTTOM_TOP, SHADOWS_COLORS);
}
setBackgroundResource(R.drawable.wheel_bg);
}
I've managed to get the horizontal wheel displaying. I dislike the method I used, but it works.
All I do is start an animation on the wheel view. Here's the rotate element I put in /res/anim with the relevant attributes.
<rotate android:fromDegrees="-90"
android:toDegrees="-90"
android:fillAfter="true" />
As I said, I dislike the implementation, but it worked for what I needed it for. I don't know how the scrolling works as it's disabled in my program, nor do I know if there's a performance hit of any kind from applying an animation in this way.
I think the question is pretty clear and can only guess why some respondents are confused. You asked how to make the Vertical Wheel component at http://code.google.com/p/android-wheel/ behave with horizontal gestures and scrolling, as described by the author (and restated in your question).
I've recently done this in my own project.
First of all, the author's assertions merely provide a conceptual framework. In practice significantly more work is involved to realize. To make the HorizontalWheel I extended WheelView AND WheelScroller and wrote code to override ALL of the logic in both classes based on height. To do this some fields in WheelView and WheelScroller needed getters/setters; as well some constants and methods needed to be accessible and set as protected or public instead of private so they could be overridden. For example, WheelView does not provide a way to inject a WheelScroller or set a custom ScrollingListener.
Finally, there's a fundamental problem in the design of the component that I've been struggling with throughout the customization. I'm struggling with the problem now. The component fundamentally treats the list of Views it contains as having a "current item" == the View in the middle of the widget. It measures scrolling and justification based on the midpoint of the View that is closest to the center of the widget. This gives the widget the snap-to-middle effect. The snap effect is nice if there are shadows that only permit one element to show. However, deviate from that use-case, say you want more than one item to be visible between the shadows or want a different snap behavior and you'll run into problems. The Component's view-recycler also doesn't support multiple View types.
I've fixed most of these things and will publish soon. If given a chance I'd rebuild this component to call the first fully-visible item == first_item. Then I'd do away with the concept of "current item" because it only makes sense for the use-case in the screenshots and makes extending and customizing the component needlessly more difficult. Undoutedly snap-to-middle, left, and right seem like required features too, and should be configurable.