Android设备上的WebView内容(网站)很大

时间:2015-02-02 08:55:44

标签: android webview

我用webview创建了一款Android应用。在Android模拟器中,我可以滚动网站,直到它与webview相匹配。但是在一个真正的Android设备上,我无法滚动到网站内容与webwiew匹配,它是大的。为了让网站与网页浏览相匹配,我需要做些什么?

我希望你理解我的问题并且可以帮助我!?

3 个答案:

答案 0 :(得分:0)

        this.mWebView.getSettings().setJavaScriptEnabled(true);
        this.mWebView.getSettings().setUseWideViewPort(true);
        this.mWebView.getSettings().setLoadWithOverviewMode(true);
        this.mWebView.getSettings().setRenderPriority(RenderPriority.HIGH);

如果您提及上述设置,webview可以正确呈现您的网站。

答案 1 :(得分:0)

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:webviewapp="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:id="@+id/container_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <android.support.v4.widget.SwipeRefreshLayout
            android:id="@+id/container_swipe_refresh"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1">

            <WebView
                android:id="@+id/fragment_main_webview"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@color/global_bg_front" />

        </android.support.v4.widget.SwipeRefreshLayout>

        <com.google.android.gms.ads.AdView
            android:id="@+id/fragment_main_adview"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            webviewapp:adUnitId="@string/admob_unit_id"
            webviewapp:adSize="BANNER" />

    </LinearLayout>

    <include layout="@layout/placeholder_progress"
        android:id="@+id/container_progress"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone" />

    <include layout="@layout/placeholder_offline"
        android:id="@+id/container_offline"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone" />

    <include layout="@layout/placeholder_empty"
        android:id="@+id/container_empty"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone" />

</FrameLayout>

答案 2 :(得分:0)

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:webviewapp="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:id="@+id/container_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <android.support.v4.widget.SwipeRefreshLayout
            android:id="@+id/container_swipe_refresh"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1">

            <WebView
                android:id="@+id/fragment_main_webview"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@color/global_bg_front" />

        </android.support.v4.widget.SwipeRefreshLayout>

        <com.google.android.gms.ads.AdView
            android:id="@+id/fragment_main_adview"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            webviewapp:adUnitId="@string/admob_unit_id"
            webviewapp:adSize="BANNER" />

    </LinearLayout>

    <include layout="@layout/placeholder_progress"
        android:id="@+id/container_progress"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone" />

    <include layout="@layout/placeholder_offline"
        android:id="@+id/container_offline"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone" />

    <include layout="@layout/placeholder_empty"
        android:id="@+id/container_empty"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone" />

</FrameLayout>









<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/activity_main_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <FrameLayout
        android:id="@+id/activity_main_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <ListView
        android:id="@+id/activity_main_drawer"
        android:layout_width="@dimen/drawer_width"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:choiceMode="singleChoice"
        android:drawSelectorOnTop="false"
        android:fastScrollEnabled="false"
        android:dividerHeight="@dimen/drawer_item_divider"
        android:divider="@color/drawer_item_divider"
        android:cacheColorHint="@android:color/transparent"
        android:listSelector="@android:color/transparent"
        android:background="@color/drawer_bg" />

</android.support.v4.widget.DrawerLayout>