Android:示例以滚动显示WebView [英] Android: sample to show WebView with scrolling
本文介绍了Android:示例以滚动显示WebView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这应该是非常基本的,我只是不知道怎么做.我有一个显示页面的webView太长,无法一次显示所有页面.现在,它显示了滚动条,但实际上并没有滚动.只是有点摆动,足以让您知道它是一个活动的滚动条.
This should be pretty basic, I just can't find out how. I have a webView that shows a page to is too long to show all at once. Right now, it shows the scroll bar, but it doesn't really scroll. It just kinda wiggles a little bit just enough to let you know it's an active scroll bar.
希望在xml布局中,我想尽可能使页面滚动以显示整个页面.
Hopefully, in the xml layout, as much as possible, I would like to have the page scroll as needed to show the whole page.
我的xml布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView
android:id="@+id/news_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
onCreate呼叫:
onCreate call:
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.news);
WebView webView = (WebView) findViewById(R.id.news_view);
webView.setVerticalScrollBarEnabled(true);
webView.loadUrl("http://www.example.com/index.html");
}
推荐答案
您是否考虑过使用ScrollView?
did you think about using ScrollView ??
<ScrollView android:layout_width="fill_parent"
android:layout_height="86px"
android:id="@+id/scrollTxtDescription"
android:layout_below="@id/txtLieuPromo1"
android:layout_alignLeft="@id/txtLieuPromo1">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/layoutTxtDescription"
>
<WebView android:id="@+id/txtDescription"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
</ScrollView>
这篇关于Android:示例以滚动显示WebView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文