I am trying to make toolbar gradient with transparent but nothing is working. Here is my code.
activity_main.xml (Updated)
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.amrat.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/gradient"
android:theme="@style/AppTheme.AppBarOverlay"
app:elevation="0dp">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@drawable/gradient"
android:layout_alignParentBottom="true"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" />
</android.support.design.widget.CoordinatorLayout>
gradient.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="270"
android:endColor="#00ffffff"
android:startColor="#ffffff"
android:type="linear" />
</shape>
Trying to do like this:

But got this:

Please help me if anyone knows how to do this.
UPDATE
AndroidManifest.xml
<activity
android:name=".activity.MainActivity"
android:theme="@style/AppTheme.Transparent.NoActionBar" />
style.xml
<item name="colorPrimary">@android:color/transparent</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="colorControlNormal">@color/light_grey_1</item>
<item name="colorControlActivated">@color/orange_1</item>
<item name="colorControlHighlight">@color/light_grey_2</item>
</style>
Use @android:color/transparent directly. Follow this one -
toolbar layout -
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@drawable/background_toolbar_transparent" />
background_toolbar_transparent.xml
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="270"
android:endColor="@android:color/transparent"
android:startColor="@color/black_alpha"/>
</shape>
Add a color with alphaon colors.xml -
<color name="black_alpha">#66000000</color>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With