将列表视图添加到画布
你好 是否可以将自定义列表视图添加到画布并将画布旋转一定程度,以便列表视图看起来像是旋转的
Hi
Is it possible to add a custom list view to a canvas and rotate the canvas to some degrees so that the list view seems to be rotated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过重写 ListView 子类中的 draw() 方法来完成此操作,但如果更改很小,实际上最简单的方法是简单地应用旋转动画,如下所示:
请注意,这使用 2.3 及以下兼容版本动画框架(不是较新的 3.0+ 唯一框架),这意味着视图并未真正旋转,它只是看起来旋转——这意味着点击仍然会注册,就好像列表处于其原始位置,对于超过几度的更改会明显扰乱拖动/滚动/单击交互(在这种情况下,您需要实际覆盖
draw(Canvas canvas)
在自定义 ListView 中子类化并应用必要的转换)。You can do this by overriding the draw() method in a ListView subclass, but if the change is minor, it actually may be easiest to simply apply a rotation animation such as this one:
Note that this uses the 2.3-and-below compatible animation framework (not the newer 3.0+ only framework), which means that the view isn't really rotated, it only looks rotated -- this means clicks still register as if the list was in its original position, which for changes more than a few degrees will noticeably mess up drag/scroll/click interactions (in which case you'll want to go with actually overriding
draw(Canvas canvas)
in a custom ListView subclass and apply the necessary transformations).