I've googled for hours trying to find an answer to this seemingly obvious question but I can't even find another example of someone trying to do this. Is it possible to have a gradient extend from an Android actionbar down in to tabs as per the mock up below.
Creating the gradient in the actionbar or the tabs is straightforward but a continuous gradient currently escapes me
as requested here is the gradient xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="135"
android:endColor="@color/colorPrimary"
android:startColor="@color/colorAccent" />
</shape>
I've built the tabs like this but I haven't included any attempt at a gradient here as everything I have tried is so terrible its not worth posting. The closest I came was recreating the gradient but thats rubbish
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/item_menu_ok"
android:icon="@drawable/ic_action_ok"
android:title="@string/ok"
myapp:showAsAction="ifRoom"></item>
<item android:id="@+id/item_menu_cancel"
android:icon="@drawable/ic_action_cancel"
android:title="@string/cancel"
myapp:showAsAction="ifRoom"></item>
<item android:id="@+id/item_menu_third"
android:icon="@drawable/ic_action_third"
android:title="@string/third"
myapp:showAsAction="ifRoom"></item>
</menu>
You might consider ditching ActionBar for the more modern ToolBar
That would enable you to make the TabLayout a child of the Toolbar view, make it transparent and set the gradient as a background for Toolbar
Other reasons for switching over to using Toolbar are discussed in "Should we replace Action Bar by ToolBar?"