當新增一個有WebView的Fragment時,WebView顯示出內容。
解決辦法暫時有兩種:
1、如下,使用android.R.id.content,代替你的布局,我的是LinearLayout,但是使用android.R.id.content,Fragment會覆蓋原布局的內容,此內容不會清除。
- getFragmentManager().beginTransaction().add(android.R.id.content,one,"qe").commit();
2、如下,使用FrameLayout代替LinearLayout,此時不會像android.R.id.content覆蓋掉原布局的東西,而是根據FrameLayout所在layout進行布局
- <FrameLayout
- android:id="@+id/my_fragment"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- />
暫時只是記錄解決的方法,從以上兩種解決方案看出,布局對於嵌入到Fragment的WebView的內容顯示是有影響的,改天再查明是什么原因。
