2

What is the best way to handle the situation where I have fragments that should not include a ToolBar (Those would be handle by the Activity) and some including the Toolbar? I know how to make it transparent, but how can I create a template that can easily be modular to handle both situation?

For a specific Fragment I want a transparent Toolbar with the Fragment content partly behind the Toolbar like this: enter image description here

I tried to have another FrameLayout that cover all the screen and then is replace by the FragmentTransaction but nothing happens...

    <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=".activityv2.ActivityHome">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:orientation="vertical">

        <include layout="@layout/action_bar" />

        <FrameLayout
            android:id="@+id/content_frame"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </LinearLayout>

    <LinearLayout
        android:id="@+id/left_drawer_item"
        android:layout_width="200dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:alpha="0.92"
        android:background="@color/gray_very_dark"
        android:orientation="vertical">



    </LinearLayout>

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/full_content_frame"
        android:background="@color/dark_red"
        android:fitsSystemWindows="true"/>

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

For the fragment that doesn't require a Toolbar, I replace the FrameLayout "content_frame" and for the one that require an invisible ToolBar I replace "full_content_Frame". For the second one, nothing happens when I replace it. Here is the code to replace the fragment:

private void selectProfilFragment() {
    BackHandledFragment fragment = new FragmentUserProfil();
    setSelectedFragment(fragment);
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.setCustomAnimations(R.anim.pull_in_right, R.anim.push_out_left, R.anim.pull_in_left, R.anim.push_out_right);
    ft.replace(R.id.full_content_frame, fragment)
            .addToBackStack(fragment.getTagText())
            .commit();

    setTitle("Profil");
    mDrawerLayout.closeDrawer(mDrawerLinear);
}
Jaythaking
  • 2,200
  • 4
  • 25
  • 67
  • Possible duplicate of [How to make Toolbar transparent?](http://stackoverflow.com/questions/26505632/how-to-make-toolbar-transparent) – Wilder Pereira Apr 06 '16 at 17:32
  • The issue isn't how to make it transparent, but more like how having the fragment behind it while it's transparent...And handle to opposite case where it shouldn't be behind it... – Jaythaking Apr 06 '16 at 17:34

0 Answers0