如何在ViewGroup中使用Scroller(android)
我有一个自定义 ViewGroup,想为其添加滚动功能。
是否可以使用 Scroller 对象并将其与视图组链接起来?
我在某处读到 Scroller 不执行任何实际滚动。这意味着它必须将滚动责任委托给 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?
I have read somewhere that Scroller does not do any actual scrolling. That means it must be delegating the scrolling responsibility back to ViewGroup.
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ScrollView 对象允许滚动。基本上,大多数视图都可以滚动,但它们无法将触摸事件传播到 View 类。
ScrollView
为用户处理这个问题,因此只要您想为某个视图启用滚动,就应该将其包裹在该视图周围。请记住,ScrollView 只能有一个子视图,因此如果您需要在同一滚动布局中拥有多个视图,则需要将它们全部放在一个
LinearLayout
(或RelativeLayout
代码>,或者你决定的任何内容)。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.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
(orRelativeLayout
, or whatever you decide).