Android Webview没有滚动

Android Webview没有滚动,android,android-fragments,android-webview,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 myFa

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>
-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)
布局文件:

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>
-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)

日志猫:

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>
-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)
-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
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:尝试从IRT中删除本地句柄范围条目,忽略
01-13 22:53:37.085 7405-7405/app2.example.hp.com.myapplication W/AwContents:onDetachedFromWindow在已分离时调用。忽略
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类构造函数
01-13 22:53:37.104 7405-7405/app2.example.hp.com.myapplication D/FeatureProxyBase:getService(),serviceName=multiwindow\u service\u 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-720926#7f0b0092 app:id/mywebview}ic=org.chromium.content.browser.INPUT。AdapterInputConnection@2ad954aftba=android.view.inputmethod。EditorInfo@24b090bccontrolFlags=#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)

可以使用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>


在您的LinearLayout android:orientation=“vertical”中尝试此功能。有人知道RecyclerView没有滚动的原因吗?