Android:示例以滚动显示WebView

Jah*_*mic 1 android scroll webview

这应该是非常基本的,我只是不知道如何.我有一个显示页面的webView太长而无法一次显示.现在,它显示滚动条,但它不会真正滚动.它只是有点摆动,只是让你知道它是一个活跃的滚动条.

希望在xml布局中尽可能地让我根据需要滚动页面以显示整个页面.

我的xml布局文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
    >
    <WebView
        android:id="@+id/news_view"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

onCreate电话:

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");
}
Run Code Online (Sandbox Code Playgroud)

Hou*_*ine 7

你有没有想过使用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>
Run Code Online (Sandbox Code Playgroud)