使用は、デバイス上で動作していないあなたのコードを試してみました、これは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);
}
のコード
コードです。 – Mukunda
Reddy Pありがとうございました。私はScrollView内でLinearLayoutが見つからないので、ScrollViewとしてルートレイアウトを削除し、LinearLayoutを使用して正常に動作しました。しかし、WebViewのスクロールは、ルートレイアウトがScrollViewの場合、つまりScrollViewの下にあるWebViewスクロールが機能しない場合は機能しません。 – Mukunda