Correct method of using material theme in Lollipop and pre-Lollipop

If we want to support both Lollipop and pre-Lollipop devices for a material design application, which is the correct method?

  • Use only android support library: only use library support for the whole application and don't use any API 21. I tested this and it works in emulator. I can get material functions in a Lollipop device in an emulator.

  • Use both API 21 and Android Support Library at the same time in your application: specify alternate styles, alternate layouts, etc ... using API 21 and others using the Android Support Library as specified in Android.

My confusion is that if I'm going with option 1, is this the right approach for Lollipop devices? Will it be less efficient memory?

Otherwise, if I'm going with option 2, would it be overkill if it really isn't required?

Also in the second option for using the toolbar, we can have alternate layouts in two folders (layouts and layouts-v21) with the layout in the first folder using android.support.v7.widget.Toolbar

and the layout in the second folder using Toolbar

. But to set it as ActionBar

, it is enough for Lollipop that the activity inherits from the class Activity

. But pre-Lollipop must be inherited from ActionBarActivity

. Do we also need to have two activity files?

Please point out if I've ripped out any bugs.

+3


source to share


1 answer


Some features are only available in v21, like riplle effect, so if you want to use ripple effect in your application, use both back support library and v21 for lollipop. Use custom XML / Java for pre lollipop, for lollipop just add your animation / design to v21 folders.



0


source







All Articles