0

I have an application with a Toolbar and I want to make the Toolbar transparent. I have searched and got some answers but they are not working at all!

now I sign up and asking question , how should i make my Toolbar transparent? (I mean no background at all). my API is 15, android 4.0.3

<?xml version="1.0" encoding="utf-8"?>

<android.support.v7.widget.Toolbar 
 xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
local:theme="@style/ThemeOverlay.AppCompat"
local:popupTheme="@style/ThemeOverlay.AppCompat" />
Alexander Farber
  • 21,519
  • 75
  • 241
  • 416

2 Answers2

0

When you declare the Toolbar in your Java Activity, try using this code to set the Opacity/Alpha value like so:

toolbar.getBackground().setAlpha(0);

Also you could use this theme to set the background to empty

<style name="Theme.Custom" parent="@android:style/Theme.AppCompat">
    <item name="windowActionBar">false</item>
    <item name="windowActionBarOverlay">true</item>
    <item name="android:windowActionBarOverlay">true</item>
</style>

<style name="CustomActionBar" parent="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
    <item name="android:windowActionBarOverlay">true</item>
    <!-- Support library compatibility -->
    <item name="windowActionBarOverlay">true</item>
</style>

Then in your Toolbar, set the theme with this value

app:theme="@style/CustomActionBar"/>
Tobi Akerele
  • 962
  • 10
  • 20
0

set toolbar hidden: yes maybe it can work.

  • This doesn't answers the question asked by OP. If done by this method, the toolbar will be gone. The OP wants the toolbar to be transparent. – Abhishek Dutt Jun 24 '22 at 04:25
  • I am voting to close this as this has been already answered here: https://stackoverflow.com/questions/26505632/how-to-make-toolbar-transparent – Abhishek Dutt Jun 24 '22 at 04:25