2

I am assuming the backgroundSplit attribute controls what is shown as the orange line on the bottom of the CAB:

with backgroundSplit

When I go to style my CAB and change the background color, the backgroundSplit disappears.

styles.xml

 <!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="windowActionModeOverlay">true</item>
    <item name="actionModeBackground">@drawable/cab_background</item> <!-- Here -->
</style>

cab_background.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="@color/colorSecondary"/>
</shape>

without split

The same thing happens if I set actionModeBackground as a @color resource instead of @drawable.

... and when I do this:

styles.xml

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="windowActionModeOverlay">true</item>
    <item name="actionModeStyle">@style/ActionModeStyle</item> <!-- Here -->
</style>

<style name="ActionModeStyle" parent="Widget.AppCompat.ActionMode">
    <item name="background">@drawable/cab_background</item>
</style>

I modeled my drawable after the one used in the AppCompat source code:

<item name="actionModeBackground">@drawable/abc_cab_background_top_material</item>

abc_cab_background_top_material.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- This is a dummy drawable so that we can refer to the drawable ID -->
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="@android:color/white"/>
</shape>

But, as the comment notes, this is just a dummy drawable, and I can't seem to find the one actually used. I'm starting to think that backgroundSplit does not actually refer to the orange line shown in the first picture and that the colored line is written directly into the drawable file, since in the source code backgroundSplit is set to a @color/colorPrimaryDark which is not the orange color shown. If so how would that drawable file look?


On the other hand, if backgroundSplit is in fact the attribute to manipulate, is this a bug in AppCompat or am I just using it wrong?

This does nothing I can see:

styles.xml

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="windowActionModeOverlay">true</item>
    <item name="actionModeSplitBackground">@color/colorAccent</item> <!-- Here -->
</style>

... and neither does this:

styles.xml

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="windowActionModeOverlay">true</item>
    <item name="actionModeStyle">@style/ActionModeStyle</item> <!-- Here -->
</style>

<style name="ActionModeStyle" parent="Widget.AppCompat.ActionMode">
    <item name="background">@drawable/cab_background</item>
    <item name="backgroundSplit">@color/colorAccent</item>
</style>

Doesn't matter if I set backgroundSplit to a @drawable either.

young_souvlaki
  • 1,886
  • 4
  • 24
  • 28

0 Answers0