2012-01-10 7 views
0

私は昨日StackOverflowに質問を入れましたが、答えを得ることができませんでした。 答えを探す同じQuestion linkのURLを添付しています。 WebViewを使用してページをレンダリングしていて、アセットフォルダに保存されたhtmlで上下にスクロールできません。 エミュレータでは完全に動作しますが、デバイスではスクロールできません。アンドロイドのHTMLページで上下にスクロール

ご返信をお待ちしております。ありがとう。

答えて

1

使用は、デバイス上で動作していないあなたのコードを試してみました、これはXML

<ScrollView android:scrollbars="vertical" android:layout_height="wrap_content"  
    android:layout_width="fill_parent"  
    xmlns:android="http://schemas.android.com/apk/res/android"> 
    <LinearLayout 
     android:layout_height="fill_parent" android:layout_width="fill_parent" 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:orientation="vertical"> 
    <WebView android:layout_height="wrap_content" 
     android:layout_width="fill_parent" android:id="@+id/help"/> 
    <ImageButton 
     android:layout_height="wrap_content" android:layout_width="wrap_content" 
     android:id="@+id/close" android:background="@drawable/ok_button" 
     android:layout_centerHorizontal="true" android:layout_gravity="center" 
     android:layout_alignParentBottom="true"/> 
    </LinearLayout> 
</ScrollView> 

jave

のコード
try { 
     InputStream is = getAssets().open("help.html"); 

     // We guarantee that the available method returns the total 
     // size of the asset... of course, this does mean that a single 
     // asset can't be more than 2 gigs. 
     int size = is.available(); 

     // Read the entire asset into a local byte buffer. 
     byte[] buffer = new byte[size]; 
     is.read(buffer); 
     is.close(); 

     // Convert the buffer into a Java string. 
     String text = new String(buffer); 

     final String mimeType = "text/html"; 
     final String encoding = "utf-8"; 

     // Finally stick the string into the text view. 
     WebView wv = (WebView)findViewById(R.id.help); 
     wv.loadData(text, mimeType, encoding); 
    } catch (IOException e) { 
     // Should never happen! 
     throw new RuntimeException(e); 
    } 
+0

のコード

コードです。 – Mukunda

+0

Reddy Pありがとうございました。私はScrollView内でLinearLayoutが見つからないので、ScrollViewとしてルートレイアウトを削除し、LinearLayoutを使用して正常に動作しました。しかし、WebViewのスクロールは、ルートレイアウトがScrollViewの場合、つまりScrollViewの下にあるWebViewスクロールが機能しない場合は機能しません。 – Mukunda

関連する問題