如何使用滚轮在的ViewGroup(机器人) [英] How to use Scroller in ViewGroup (android)

查看:122
本文介绍了如何使用滚轮在的ViewGroup(机器人)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义的ViewGroup和想补充的滚动能力吧。

I have a custom ViewGroup and would like to add scrolling ability to it.

是否可以使用滚轮对象,并使用视图组联系起来?

Is it possible to use a Scroller object and link it up with view group?

我已经读的地方,滚轮不会做任何实际的滚动。这意味着它必须被委派负责滚动回的ViewGroup。

I have read somewhere that Scroller does not do any actual scrolling. That means it must be delegating the scrolling responsibility back to ViewGroup.

感谢

推荐答案

借助滚动型对象是什么使得滚动。基本上,大多数意见都能够滚动,但他们不传播触摸事件视图类的方法。 A 滚动型处理这对于用户来说,这样应该围绕只要你想使滚动的这一看法视图包裹。

The ScrollView object is what allows for scrolling. Basically, most Views are able to be scrolled, but they have no way of propagating touch events to the View class. A ScrollView handles this for the user, so should be wrapped around a View whenever you would like to enable Scrolling for a that view.

记住,滚动型只能有一个子视图,所以如果你需要在同一个滚动布局多个视图,你需要把它们都里面有一个的LinearLayout (或 RelativeLayout的,或任何你决定)。

Remember that a ScrollView can only have one child view, so if you need have multiple views in the same scrolling layout, you'll need to have them all inside one LinearLayout (or RelativeLayout, or whatever you decide).

这篇关于如何使用滚轮在的ViewGroup(机器人)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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