Styling the Action Bar is complicated. There are a lot of attributes you can customize and it can take some time to set it up as you need. In this article I am going to show you how to create custom style of the Action Bar within 5 minutes.
There is a great tool Android Action Bar Style Generator from Jeff Gilfelt. This web utility allows you to create a simple Action Bar style including nine patch PNG assets, XML drawables and XML styles. This is perfect but the generated XML theme is quite simple and there are some unresolved issues (e.g. indeterminate progress bar size). Also the naming convention of the assets and styles is inconsistent and little confusing for me. So I've created Action Bar style template, which is more elaborated. I use this template in all my Android projects.
Action Bar style template contains all necessary files - PNG assets, XML drawables, colors, dimens, styles. It is based on AppCompat library. Custom Action Bar style covers almost all customizable attributes. You can easily change the attributes, colors, dimens as you need. To colorize UI elements you can generate PNG assets using Android Action Bar Style Generator and copy them into the project.
Instructions how to use my Action Bar style template:
- Copy & paste all files in Res-Style into your project (exclude _extras directory).
- Open values/styles.xml, values-v11/styles.xml, values-v14/styles.xml and replace all occurences of "Example" to your own style name.
- Visit Android Action Bar Style Generator and generate colorized PNG assets.
- Copy & paste _extras/rename.bat into all drawable directories (which contains PNG files) generated via Android Action Bar Style Generator.
- Run rename.bat scripts. It will just rename PNG files to make file names more clear and consistent. All assets are prefixed with "ab" (means Action Bar).
- Copy & paste all PNG drawable files into your project. Some files are not necessary.
- Done. Now you can customize and edit styles.xml, colors.xml, dimens.xml as you need.
See example screenshots: