代码是没有问题的,其实问题就出现在LinearLayout,必须把LinearLayout改成FrameLayout,这样就有效果了,不过会有一个情况,就是重叠了。
解决方案
在相应的Fragment布局里面设置background即可
android:background="@android:color/background_light"
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="@android:color/background_light"
android:layout_height="match_parent">
<!--奇怪的bug Android中Fragment管理及重叠问题的解决方法-->
<!--解决方案
在相应的Fragment布局里面设置background即可-->
<TextView
android:id="@+id/content1"
android:layout_width="wrap_content"
android:la