Android 中画布滚动期间固定文本居中
我正在尝试为自定义视图创建水印文本,但问题是当我滚动画布时,我无法确定屏幕中心的确切坐标。 我尝试跟踪 onTouchEvent 并获取坐标,但仍然不平滑,它出现在滚动期间触摸屏幕并且并不总是居中。 有什么办法可以让绘图文本不出现在滚动中吗?
I am trying to create a watermark text to my custom view, but the problem is when I scroll the canvas, I am unable to determine the exact co-ordinates of the screen's center.
I tried tracking the onTouchEvent and getting the co-ordinates, but still it is not smooth, it appears on touching the screen during scroll and not always centered.
Is there any way to keep a drawtext out of the scroll?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用具有分层的框架布局。底层将是滚动的视图,顶层将是具有重心的文本视图。在这种情况下,当基本视图滚动时,文本视图将不会滚动。
You can use a framelayout which has to layers. The base one will be the view which scrolls and the top layer will be the textview that has a gravity center. In that case the textview will not be scroll when the base view is scrolled.