当新增一个有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的内容显示是有影响的,改天再查明是什么原因。