有没有办法获取可滚动宽度或 getContentWidth?
这让我有点疯狂,因为这似乎是一件相当简单的事情。 WebView 有一个名为 getContentHeight() 的方法,但没有 getContentWidth()。
我问了这个问题 ,这是相关的,但我也想问这个,它似乎略有不同,所以我创建了一个单独的问题。
我想找出某种方法来获取可滚动内容的总宽度。这个值显然是已知的,因为它用于确定水平滚动条的大小,但为什么没有公共访问该值?有什么方法可以得到这个值或者进行这些计算吗?
This is driving me a little crazy because it seems like a fairly straight forward thing. The WebView has a method called getContentHeight(), but it does not have getContentWidth().
I asked this question, which is related but I also wanted to ask this and it seemed it is slightly different so I created a separate question.
I want to figure out some way to get the total width of the scrollable content. This value is obviously known because it is used to determine the size of a horizontal scrollbar but why is there no public access to this value? Is there any way to get this value or make these calculations?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发现如果您对视图进行子类化,则可以调用一些受保护的方法。这些返回一些值,您可以使用它们来解决这个问题。
computeVerticalScrollExtent()
computeVerticalScrollRange()
computeVerticalScrollOffset()
I found there are some protected methods that you can call if you subclass the view. These return some values you can use to figure this out.
computeVerticalScrollExtent()
computeVerticalScrollRange()
computeVerticalScrollOffset()
capturePicture().getWidth()
我不知道为什么 getContentWidth() 函数不存在的问题:)
capturePicture().getWidth()
And i dont have the answer to the question WHY getContentWidth() function is not there :)