Webview不滚动

时间:2016-01-13 17:34:49

标签: android android-fragments android-webview

Webview在不滚动时。当我试图将其加载到我的片段中时,回收器视图正在发生。没有加载的片段是可滚动的。

以下是代码:

public class MyFragment2 extends android.support.v4.app.Fragment {
WebView webView;

public static MyFragment2 getInstance() {
    MyFragment2 myFagment2 = new MyFragment2();
    return myFagment2;
}

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View layout = inflater.inflate(R.layout.fragment_my2, container, false);
    RequestQueue requestQueue = Volley.newRequestQueue(getActivity());
    webView = (WebView) layout.findViewById(R.id.mywebview);
    //layout.setVerticalScrollBarEnabled(true);
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webView.loadUrl("http://www.shiksha.com/");
    return layout;
}
}

布局文件:

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

<WebView
    android:id="@+id/mywebview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#FFFFFF"
    android:textColor="#B6B6B6"
    android:textSize="20sp" />
 </LinearLayout>

LOGCATS:

-01-13 22:53:36.986 7405-7472/app2.example.hp.com.myapplication D/Surface: Surface::setBuffersDimensions(this=0xb45bcf00,w=720,h=1280)
01-13 22:53:37.003 7405-7472/app2.example.hp.com.myapplication D/Surface: Surface::setBuffersDimensions(this=0xb45bcf00,w=720,h=1280)
01-13 22:53:37.020 7405-7472/app2.example.hp.com.myapplication D/Surface: Surface::setBuffersDimensions(this=0xb45bcf00,w=720,h=1280)
01-13 22:53:37.037 7405-7472/app2.example.hp.com.myapplication D/Surface: Surface::setBuffersDimensions(this=0xb45bcf00,w=720,h=1280)
01-13 22:53:37.054 7405-7472/app2.example.hp.com.myapplication D/Surface: Surface::setBuffersDimensions(this=0xb45bcf00,w=720,h=1280)
01-13 22:53:37.073 7405-7405/app2.example.hp.com.myapplication D/WebView: WebView<init>
01-13 22:53:37.074 7405-7405/app2.example.hp.com.myapplication V/SettingsInterface:  from settings cache , name = show_password , value = 0
01-13 22:53:37.081 7405-7405/app2.example.hp.com.myapplication W/art: Attempt to remove local handle scope entry from IRT, ignoring
01-13 22:53:37.085 7405-7405/app2.example.hp.com.myapplication W/AwContents: onDetachedFromWindow called when already detached. Ignoring
01-13 22:53:37.094 7405-7405/app2.example.hp.com.myapplication D/WebView: loadUrl=http://www.shiksha.com/
01-13 22:53:37.104 7405-7472/app2.example.hp.com.myapplication D/Surface: Surface::setBuffersDimensions(this=0xb45bcf00,w=720,h=1280)
01-13 22:53:37.104 7405-7405/app2.example.hp.com.myapplication D/FeatureProxyBase: FeatureProxyBase class constructor
01-13 22:53:37.104 7405-7405/app2.example.hp.com.myapplication D/FeatureProxyBase: getService(), serviceName = multiwindow_service_v1
01-13 22:53:37.107 7405-7405/app2.example.hp.com.myapplication V/InputMethodManager: START INPUT: android.webkit.WebView{1fb12e91 VFEDHVC. .F...... 0,0-720,926 #7f0b0092 app:id/mywebview} ic=org.chromium.content.browser.input.AdapterInputConnection@2ad954af tba=android.view.inputmethod.EditorInfo@24b090bc controlFlags=#100
01-13 22:53:37.132 7405-7472/app2.example.hp.com.myapplication D/Surface: Surface::setBuffersDimensions(this=0xb45bcf00,w=720,h=1280)
01-13 22:53:37.141 7405-7472/app2.example.hp.com.myapplication D/Surface: Surface::setBuffersDimensions(this=0xb45bcf00,w=720,h=1280)
01-13 22:53:37.157 7405-7472/app2.example.hp.com.myapplication D/Surface: Surface::setBuffersDimensions(this=0xb45bcf00,w=720,h=1280)
01-13 22:53:37.177 7405-7472/app2.example.hp.com.myapplication D/Surface: Surface::setBuffersDimensions(this=0xb45bcf00,w=720,h=1280)
01-13 22:53:37.192 7405-7472/app2.example.hp.com.myapplication D/Surface: Surface::setBuffersDimensions(this=0xb45bcf00,w=720,h=1280)

1 个答案:

答案 0 :(得分:0)

可以使用ScrollView!

<ScrollView android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <LinearLayout android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            >

            <WebView
                android:id="@+id/mywebview"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:background="#FFFFFF"
                android:textColor="#B6B6B6"
                android:textSize="20sp" />
        </LinearLayout>
    </ScrollView>