我的网络视图显示正常,没有任何问题。但是,在应用“选定文本”功能后,Web视图仅显示在屏幕的一半上(请参阅下图)。仅在半屏上显示Android WebView
这里是我的代码:
@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
工作得很好。
我希望你们能认识到这个问题,帮我修理一下。非常感谢你。
EDITED
这里是布局:
<?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>
谢谢,我已经将它们设置为“fill_parent”。但请看看我在EDITED中的布局。 –
请粘贴content.xml的代码 – nithinreddy
那么,有人找出问题吗?请看看帮助。 –