2016-01-13 75 views
-1

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} [email protected]954af [email protected] 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) 
+0

有人知道RecyclerView没有滚动的原因吗? – iSandeep

回答

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> 
+0

已经尝试....不工作 –

+0

在你的LinearLayout android:orientation =“vertical” – Nik