内容拉伸以填充 HorizontalScrollView
我在这里做了一件不可取的事情,我知道这一点,但我有一个嵌套在水平滚动视图中的网络视图。 (我需要比 webview 提供的更多的滚动控制。)
布局如下所示:
<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webRel"
android:layout_below="@+id/titlebar"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<WebView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webZ"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</HorizontalScrollView>
结果如下:
web 视图未填满水平滚动视图。 Horizontalscrollview 正在填充视图,所以我想我可以说 webview 没有填充视图,即使我都设置为 fill_parent 。如果有人能帮我弄清楚如何让 webview 横向填充水平滚动视图,我真的非常非常喜欢...因为然后我测量高度并使用该测量值对文本进行分页(然后以块的形式横向显示)这就是我选择水平滚动视图的原因。)
:D
(或者,关于在网络视图中实现平滑水平滚动的更清晰方法的建议也会很有帮助。)
I'm doing an inadvisable thing here, and I know it, but I have a webview nested in a horizontalscrollview. (I needed more scrolling control than webview provides.)
The layout looks like this:
<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webRel"
android:layout_below="@+id/titlebar"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<WebView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webZ"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</HorizontalScrollView>
And the results are as follows:
The webview isn't filling up the horizontalscrollview. The horizontalscrollview is filing the view, so I guess I could say the webview isn't filling the view even though I have both set to fill_parent. I would really, really like it if someone would help me figure out how to have the webview fill up the horizontalscrollview widthwise... because then I measure the height and use that measurement to paginate the text (which is then displayed in chunks widthwise which is why I chose horizontalscrollview.)
:D
(Alternatively, suggestions for a cleaner way to have smooth horizontal scrolling in a webview would also be helpful.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
答案是:使用android:fillViewPort。它将让滚动视图的内容拉伸以填充视图。
The answer is: use android:fillViewPort. It'll have the contents of the scrollview stretch to fill the view.
WebView 已经支持水平滚动,您不应该将其放在 HorizontalScrollView 中。
WebView already supports horizontal scrolling, you should not put it inside a HorizontalScrollView.