片段的白色背景显示为透明

时间:2015-09-13 08:20:22

标签: android xml android-layout android-fragments

即使在应用白色背景后,片段后面的活动也是可见的。

Fragment1.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:layout_gravity="start"
    android:clickable="true">
...

</RelativeLayout>

这就是我调用片段的方式

            getSupportFragmentManager().beginTransaction().add(R.id.content_frame, fragment, "Secondary_Fragment").addToBackStack(null).commit();

这就是我使用布局的方式..

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    ViewGroup view = (ViewGroup) inflater.inflate(R.layout.fragment1, null);
    init(view);

    return view;
}

和颜色是

<color name="white">#ffffff</color>

这是主要活动的xml

<LinearLayout
    android:id="@+id/container_toolbar"
    android:background="@color/white"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

<include
    android:id="@+id/toolbar"
    layout="@layout/toolbar" />

<FrameLayout
    android:id="@+id/content_frame"
    android:background="@color/white"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
</LinearLayout>

问题在所有Android版本上都不可见。带有Cyanogen OS的Yureka Plus,Android 5.0.2正在显示这个问题。

还有一件事我观察到..如果我使用除白色以外的任何其他颜色..问题没有出现..这是设备的问题还是我的代码中的一些问题?

0 个答案:

没有答案
相关问题