android, materialdesign, android-support-library
Since Android L(ollipop) was presented in June at Google I/O, only two devices on market can run it officially. Nexus 6 and Nexus 9 were released a week ago, and these two guys are ready to go with most recent system from Google, but what about other devices? My Nexus 5 still tryin update everyday, but still no effects :)
Hopefully, we can use some part of Material Design with devices running Android 2.1 and higher, because most of implementation was placed in android-support-v7.
I wrote simple app which displays images in grid with possibility to pick them to see them in full size with ActionBar colors based on picked image. App uses new classes: Palette and Toolbar.
It’s looks like this:
All dependencies we need:
as you can see Google split android.support and put Palette as separate lib (similar to RecyclerView and CardView). I used Picasso to simple load images from web.
Next, define AppTheme with parent as Theme.AppCombat. You can also specify colorPrimary and accentColor which are used by framework to color surface background of widgets such as text fields, checkboxes etc.
Apply style to application:
App has two activities. First MainActvity extends ActionBarActivity so framework will show window with ActionBar (see first screenshot with GridView). ImageActivity is just Activity, so by default window will be rendered without ActionBar. But look at other screenshots, they have an ActionBar, but wait… actually it’s Toolbar!
Toolbar is more flexible (easier to customize) standardView, so you can put it everywhere in layout, multiple times… and it still can act as ActionBar (see setActionBar)
Let’s look at the layout file:
It’s simple. Nothing special here, except using of Toolbar.
Finally we can use Pallete to extract prominent colors from image and change style of Toolbar at runtime.
Look at the screenshots, I think they look pretty well and we didn’t need a graphic designer to choose correct colors ;)