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 布局文件:
my xml layout file:
<?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屋!
查看全文