3

I want to set background of toolbar transparent.

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/transparent"
    android:theme="@style/ThemeOverlay.AppCompat.Dark"
    android:elevation="4dp"
    android:id="@+id/tool_bar_org"
    android:paddingTop="0dp">

</android.support.v7.widget.Toolbar>

Here is my toolbar layout background is not being transparent

just show in white color

 toolbar = (Toolbar) findViewById(R.id.tool_bar_org);
 toolbar.getbackgroud().setAlpha(0);
 setSupportActionBar(toolbar);

Its not working. Can you please tell me how to make it transparent.

Bhuvnesh
  • 1,055
  • 9
  • 29

1 Answers1

0

This is the theme I have used in my project to make the appCompact ActionBar as transparent, modify it according to your needs:

<style name="adhoctheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="android:actionBarStyle">@style/adhocblack</item>
        <item name="actionBarStyle">@style/adhocblack</item>
        <item name="android:windowActionBarOverlay">true</item>
        <item name="windowActionBarOverlay">true</item>
    </style>

    <style name="adhocblack" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
        <item name="android:background">#0D000000</item>
        <item name="background">@color/appcompact_transparent_actionbar_bg</item>
        <item name="android:icon">@drawable/logo_header_2</item>
    </style>

Where appcompact_transparent_actionbar_bg = #0D000000

Important:

Have a look here to check how different values folders contain specific style files to render on various API's

Community
  • 1
  • 1
Skynet
  • 7,820
  • 5
  • 44
  • 80
  • let me check this Thanks – TiaraJewellery Shop May 15 '15 at 06:57
  • [imagescreen](https://www.dropbox.com/s/htfmyzj3vijkxhj/Capture.PNG?dl=0) this is screen shot .when iused your theme i want to show toolbar on image mean image is below to toolbar – TiaraJewellery Shop May 15 '15 at 07:04
  • For that you have to add the image to the toolbar, actually your problem is not quite clear. Please provide more examples. What API are you testing on? Please take note of how values folders are used to render different styles for different API's – Skynet May 15 '15 at 07:11
  • The Example Is Google play store when we click on any app toolbar is showing on the below image banner ..... – TiaraJewellery Shop May 15 '15 at 07:15
  • [Check this guide](https://developer.android.com/training/basics/actionbar/overlaying.html) and [this](https://github.com/ksoichiro/Android-ObservableScrollView) library – Skynet May 15 '15 at 07:15
  • i Used true this item overlaying is not done – TiaraJewellery Shop May 15 '15 at 07:20
  • What is the API you are testing on? DId you use AppCompact as the parent theme? – Skynet May 15 '15 at 07:24
  • [Check a similar problem here](http://stackoverflow.com/questions/26505632/how-to-make-toolbar-transparent) – Skynet May 15 '15 at 07:29