0

I started with development with material design.

My layouts and styles are separated in those for pre-lollipop devices and those for lollipop and higher.

E.g i use

<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
style="@style/Toolbar" />

In my pre-lollipop layout file and

<Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
style="@style/Toolbar" />

in the other one. Therefore I am forced to use two different objects in the related activity class. That confuses me a lot and leads to confusing code.

I know how to distinguish between API levels via

Build.VERSION.SDK_INT

Nevertheless what is the best approach to solve this problem?

Thank you for answers

  • don't mix it like this. Use the one from `support` for as long as your minApi is smaller than 21 – Budius Mar 06 '16 at 18:34
  • Actually I wanted to avoid the use of another library but indeed it seems to be the best solution –  Mar 06 '16 at 18:53
  • Android support library is not "just another library" it is an absolute essential tool for developers. – Budius Mar 06 '16 at 18:55
  • Thanks for this hint. Yet I'm not very experienced in this Android stuff :) –  Mar 07 '16 at 22:08

1 Answers1

0

i usually use android.support.v7.widget.Toolbar, because it's compatible with other API. The regular one will give you a lot of problems if you use it a lot in your code.

Xeijin
  • 74
  • 5