1

I want the ToolBar to be transparent. I have an Activity that is showing a Toolbar and looks like this:

enter image description here

I have this on my xml:

 <android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:elevation="0dp"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@android:color/transparent" />

</android.support.design.widget.AppBarLayout>

But I can't make my Activity be on top and be visible at the back of my ToolBar...

How can I achieve this?

Sonhja
  • 8,230
  • 20
  • 73
  • 131

2 Answers2

2

StackOverflow does not allow me to comment because I don't have 50 reputation that why I am commenting in answer box

You can find you answer here:

How to make the support Toolbar background transparent?

How to make Toolbar transparent?

Community
  • 1
  • 1
Raza Ali Poonja
  • 1,086
  • 8
  • 16
1

@RAP's answer seems work. But note that if you set the background to transparent, means that the toolbar is still clickable when user touch on it and doing some actions you don't want. Other alternative to achieve your goal is by setting its visibility to INVISIBLE:

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

toolbar.setVisibility(View.INVISIBLE);

// to make it appear again:
toolbar.setVisibility(View.VISIBLE);
Anggrayudi H
  • 14,977
  • 11
  • 54
  • 87