如何让Android轮的水平? [英] How to make android-wheel horizontal?

查看:154
本文介绍了如何让Android轮的水平?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图采取了Android轮从的http:// code.google.com / P /机器人轮/ ,并把它显示水平。我的第一次尝试,以实现这一目标来自一个建议,由作者本人的 http://android-devblog.blogspot.com/2010/05/wheel-ui-contol-backgrounds.html 在评论部分的底部。

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 by the author himself http://android-devblog.blogspot.com/2010/05/wheel-ui-contol-backgrounds.html at the bottom of the comments section.

康康:简单的方法:使用垂直轮,但旋转画布拉伸前在此情况下,它需要也改变onTouch和交换X和Y触摸坐标滚动

kankan: "The easy way: use the vertical wheel, but rotate the canvas before drawing. In this case it needs also to change the onTouch and swap x and y touch coordinates for scrolling."

我的实现是很简单的,我伸出WheelView,只是旋转画布90度的OnDraw方法(我不关心触控部,车轮是不是交互)。不幸的是它是所有打开数字本身就在自己身边,车轮窗口保持垂直。

My implementation is very simple where I extend WheelView and just rotate the canvas by 90 degrees in the onDraw method (I'm not concerned with the touch portion, the wheel is not for interaction). Unfortunately all it does is turn the numbers themselves on their side, the wheel window stays vertical.

有没有人有horizo​​ntalizing的wheelview的经验吗?

Does anyone have any experience with horizontalizing the wheelview?

推荐答案

我认为这个问题是pretty的清晰,只能猜测为什么有些受访者感到困惑。你问如何使纵轮分量的http:// code。 google.com/p/android-wheel/~~V 表现得有水平的手势和滚动,由作者所描述的(并重申在你的问题)。

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.

首先,作者的说法只是提供了一个概念框架。在实践中显著更多的工作是参与来实现。为了使Horizo​​ntalWheel我伸出WheelView和WheelScroller并写了code覆盖所有的逻辑的基础上的高度这两个类。为此,在WheelView和WheelScroller需要getter / setter方法​​的一些领域;还有一些常量,需要被访问,并设置为受保护或公开,而不是私有,因此他们可能被覆盖的方法。例如,WheelView不提供一种方式来注入WheelScroller或设置自定义ScrollingListener

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.

最后,有一个在我一直挣扎着整个定制组件的设计的一个基本问题。现在我挣扎的问题。该组件从根本上治疗意见的清单包含为具有当前项目==查看在widget的中间。它测量的滚动和理由的基础上认为是最接近部件中心的中点。这使插件的捕捉到中间的效果。该卡效果是很好的,如果有阴影了只允许一个元素来展现。然而,从用例偏离,说你要多个项目是阴影之间的可见或想要一个不同的捕捉行为,你会遇到的问题。组件的观点,回收也不支持多种视图类型。

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.

我已经解决了大部分的这些事情,并会尽快公布。如果有机会我会重建这个组件调用第一个完全可见项目== FIRST_ITEM。然后我会弄死当前项目的概念,因为它不仅使意义的用例的截屏,使扩展和自定义组件不必要更加困难。不可否认的是捕捉到中间,左,右看似所需的功能太多了,应该是可配置的。

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.

这篇关于如何让Android轮的水平?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆