Web ビューは問題なく表示されました。ただし、「選択したテキスト」機能を適用した後、Web ビューは画面の半分にしか表示されません (下の画像を参照)。
これが私のコードです:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.content);
Intent i = this.getIntent();
final int wordId = i.getIntExtra("id", -1);
mCurrentWord = i.getStringExtra("word");
mSelectedDB = i.getStringExtra("db");
mContentStyle = i.getStringExtra("style");
prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
loadHistoryFromPreferences();
loadFavouriteFromPreferences();
wvContent = (WebView) findViewById(R.id.wvContent);
initWebview();
String content = getContentById(wordId);
showContent(content);
//This is the beginning of what I added
webkit=new Webkit(this);
wvContent.addView(webkit);
WebkitSelectedText webkitSelectedText=new WebkitSelectedText(getApplicationContext(), webkit);
webkitSelectedText.init();
wvContent.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
//This is the end of what I added
私は自分が何を間違ったことをしたのか分かりません。この表示の問題を除いて、新しく追加されたものを含む他のすべての機能は問題Selected text
なく動作します。
皆さんが問題を認識し、それを修正するために私に恩恵を与えてくれることを願っています. どうもありがとうございました。
編集済み
レイアウトは次のとおりです。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="bottom|fill_vertical"
>
<LinearLayout xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical"
android:layout_weight="1"
>
<WebView
android:id="@+id/wvContent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="top"
android:layout_weight="1"
/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
>
<ImageButton
android:id="@+id/btnHome"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="@drawable/home"
android:layout_weight="0.25"
/>
<ImageButton
android:id="@+id/btnPronounce"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="@drawable/pronounce"
android:layout_weight="0.25"
/>
<ImageButton
android:id="@+id/btnShowHistory"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="@drawable/history"
android:layout_weight="0.25"
/>
<ImageButton
android:id="@+id/btnAddFavourite"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="@drawable/add_favourite"
android:layout_weight="0.25"
/>
</LinearLayout>