Le fragment a un fond blanc par défaut sur replace () au lieu d'un transparent

Je suis confronté à un problème étrange tout en utilisant des fragments et juste ne peux pas le comprendre.

Quand je suis en remplacement de fragments à l'intérieur de mon MainActivity conteneur, certains ont souhaité garder l'arrière-plan transparent, et certains vont montrer un défaut comme un blanc. En fait je veux que tous mes fragments de transparence et de "l'usage" de l'arrière-plan assigné à la MainActivity.

Par exemple:
Fragment A: arrière-plan blanc

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:id="@+id/image"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:paddingLeft="10dp"
        android:paddingRight="10dp"
        android:src="@drawable/logo"/>

    <de.mypackage.uielements.MyButton
        android:id="@+id/button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:text="@string/button_text"/>    

    **<!-- ListView to show news -->**
    <ListView
        android:id="@+id/listview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:dividerHeight="1dp"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:layout_marginBottom="10dp"/>
</LinearLayout>

Fragment B: arrière-plan transparent

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ListView
        android:id="@+id/listview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</LinearLayout>

main.xml

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <!-- Background Image to be set programmatically, transparent being default -->
    <ImageView
        android:id="@+id/window_background_image_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="centerCrop"
        android:background="@android:color/transparent"/>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/transparent">

        <!-- Top ScrollView -->
        <de.opwoco.app.android.apptitan.app.utils.HorizontalListView
            android:id="@+id/navigation_tab_listview"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:visibility="gone"
            android:background="@color/navigation_background"/>

        <!-- FrameLayout container where all other fragments are placed -->
        <FrameLayout
            android:id="@+id/container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@android:color/transparent"
            android:layout_below="@+id/navigation_tab_listview"/>

    </RelativeLayout>

    <fragment
        android:id="@+id/navigation_drawer"
        android:layout_width="@dimen/navigation_drawer_width"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:name="de.mypackage.fragment.NavigationDrawerFragment"
        tools:layout="@layout/fragment_navigation_drawer"/>

</android.support.v4.widget.DrawerLayout>

Les deux fragments sont remplacés par l'utilisation de l'extrait de code suivant:

android.support.v4.app.FragmentTransaction transaction =     getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.container, fragment);
transaction.commit();

Donc ma question est:

Comment puis-je réaliser que tous les fragments dans mon conteneur avoir un fond transparent, de sorte que je suis toujours montrer le fond assigné dans le MainActivity?

source d'informationauteur W3hri