Reputation: 91
I want to create a customised action bar. Which will be combining the app theme colour with the gradient overlay to get a new gradient. I have pasted my gradient file and the background colour codes. Can anyone tell me how to do this?
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
android:useLevel="false" >
<gradient
android:angle="0"
android:startColor="@color/gradient_start_colour"
android:endColor="@color/gradient_end_colour"
android:type="linear" />
</shape>
And theme colour for app is #0097a7
. Can anyone tell me if this is possible and if yes, how to do it?
Upvotes: 0
Views: 543
Reputation: 11642
You can create drawable like this,
drawable/toolbar_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#0097a7"/>
<gradient
android:angle="9"
android:endColor="#FFF"
android:startColor="#55FFFFFF"
android:type="linear"/>
</shape>
</item>
</layer-list>
and in toolbar you can give background like this,
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@drawable/toolbar_bg"
app:popupTheme="@style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
Upvotes: 1