Android 中是否可以实现可缩放滚动视图,并且滚动条在视口中可见?
我正在尝试开发一个可缩放的卷轴,看到两个滚动条可见。但是实施时,我将面临以下问题。
要启用方向,请使用scrollview和Horifontal ScrollView。在这种情况下,只有垂直滚动条在视口上可见,并且水平滚动栏在内容的底部可用。我们需要滚动到结尾以查看它。但是我可以看到像Gmail之类的应用程序,在Android中的Chrome,其中两个滚动条在视口上可见。怎么可能?
将比例尺应用于内容时,内容物会缩放并剪切在滚动浏览中。它需要调整内容。调整大小时,更改了内容的枢轴值,并且在必需的触摸指针上不会应用缩放到缩放。但是许多Android应用程序可以完美地做到这一点。
谁能建议或为我提供实现上述两个的线索?
用Xamarin Android溶液会更好。但是,欢迎任何想法。
I am trying to develop a zoomable scrollview with seeing both the scrollbars visible. But when implementing I face the following issues.
To enable both Orientation, use scrollview and horizontal scrollview. In this case only the vertical scrollbar is visible in the viewport and the horizontal scrollbar is available at the bottom of the content. We need to scroll to the end to see it. But I could see apps like Gmail, chrome in Android where both the scrollbars are visible in the viewport. How is this possible?
When applying scale to the contents, the contents are scaled and clipped inside the scrollview. It requires content resizing. When resizing, the pivot value of the contents are changed and pinch to zoom is not applied at the required touch pointers. But many android apps do this flawlessly.
Can anyone suggest or provide me a clue to achieve the above two?
Solution with Xamarin Android will be better. However, any ideas are welcome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果没有看到您的代码,第 1 项和第 2 项很难回答。
但
我已经实现了一个带有固定标题的可缩放和可滚动表(请参阅 https://github.com/Zardozz/FixedHeaderTableLayout 可能会给你一些关于我如何克服类似问题的提示)
对于滚动条,我为我的滚动条扩展了一个 FrameLayout,这就是将滚动条实现为顶级父 ViewGroup 的原因,因此滚动条始终位于外边缘的底部和右侧,并保留在屏幕上。
这是通过在 ViewGroup 中设置
setWillNotDraw(false);
并实现computeHorizontalScrollRange
和computeHorizontalScrollOffset
方法(以及垂直方法)来 完成的缩放我通过将
onMeasure
覆盖为intmeasureSpec = 来测量子 ViewGroups(子表部分) MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
因此,子 ViewGroup 的大小会调整为所需的大小,并且不会裁剪到父级的大小,因此当您缩放视图时,它会具有通常的大小应用比例因子时在屏幕外进行绘制。
更新:
忘了说,我只是通过重写父视图中的
drawChild
方法来缩放子视图。Item 1 and 2 are difficult to answer without seeing your code.
But
I've implemented a zoomable and scrollable Table with Fixed headers (see https://github.com/Zardozz/FixedHeaderTableLayout might give you some hints on how I overcame similar problems)
For scrollbars I extended a FrameLayout for mine, this is what implements the scrollbars as the top level parent ViewGroup, thus the scrollbars are always on the bottom and right of the outside edge and stay on the screen.
This was done by setting
setWillNotDraw(false);
in the ViewGroup and by implementingcomputeHorizontalScrollRange
andcomputeHorizontalScrollOffset
methods (as well as the vertical ones)For Zooming I measure the children ViewGroups (The sub table parts) by overriding their
onMeasure
toint measureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
Therefore the children ViewGroups are sized to be as big as they want to be and not clipped to the parents size, thus when you scale the view it has something that is normally offscreen to draw when a scale factor is applied.
Update:
Forgot to say that I only scale the child views by overriding
drawChild
method in the parent.