4

I'm upgrading an app to use AppCompat v7 21.0.0.

I haven't migrated to Toolbar yet and am instead trying to theme the Window decor ActionBar. I am using NAVIGATION_MODE_LIST and a ShareActionProvider in the action bar. The navigation mode is set like this:

getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

However the spinner dropdown covers the spinner and is the dark. Here's an image of the issue: https://i.stack.imgur.com/kNwdm.png

I want the drop down to appear under the action bar and be larger than the spinner. I've tried to adjust the theme in many ways but nothing I do seems to have any effect on the spinner dropdown.

This is the theme

<style name="AppTheme.Blue" parent="@style/Theme.AppCompat.Light.DarkActionBar">
  <item name="colorPrimary">@color/theme_blue</item>
  <item name="colorPrimaryDark">@color/theme_blue_dark</item>
  <item name="colorAccent">@color/theme_blue_accent</item>
</style>

The ShareActionProvider in the same action bar shows the same issue as in this question about Toolbar so migrating to Toolbar won't solve both issues: AppCompat ToolBar popupTheme not used in the ShareAction MenuItem

Community
  • 1
  • 1
user3209486
  • 198
  • 3
  • 7

1 Answers1

5

With the api21 the method setNavigationMode(ActionBar.NAVIGATION_MODE_LIST) is deprecated, then be carefully to use it.

http://developer.android.com/reference/android/support/v7/app/ActionBar.html#setNavigationMode(int)

This answer doesn't resolve your issue, but it is another way to achieve it with the new Toolbar class. The Toolbar is a ViewGroup so you can use a Spinner inside it.

<android.support.v7.widget.Toolbar
        android:id="@+id/toolbar_actionbar"
        android:layout_height="?attr/actionBarSize"
        android:layout_width="match_parent"
        android:background="?attr/colorPrimary">

    <Spinner
            android:id="@+id/spinner_toolbar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

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

Then you can use the toolbar as actionbar using:

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
setSupportActionBar(toolbar);

Finally you have to disable the title inside the toolbar:

getSupportActionBar().setDisplayShowTitleEnabled(false);
Matthieu Coisne
  • 624
  • 1
  • 13
  • 25
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • Thanks Gabriele. I was hoping to avoid the work of replacing action bars with toolbars for at least the first material release but I've gone through the process and got most things working now and it has moved the drop down to under the toolbar and I expect I'll be able to easily theme it now. – user3209486 Oct 24 '14 at 05:35