Android Material Design AppCompat

I am new to Android material design concept. I created a new project and added a material theme with AppCompat support for pre-Lellipop versions, but my problem is that in Lollipop it displays the ActionBar aka Toolbar, but if I run the same in pre-lollipop it does not display the ActionBar.

Should I just use the toolbar control everywhere in my layout, regardless of the version of the API?

Edited by:

<!-- Base application theme for prelollipop --> <style name="AppTheme" parent="Theme.AppCompat.Light"> <item name="colorPrimary">@color/primary_dark</item> <item name="colorPrimaryDark">@color/primary_dark</item> </style> <!-- Material theme for lollipop--> <style name="AppTheme" parent="android:Theme.Material.Light"> <item name="android:colorPrimary">@color/primary</item> <item name="android:colorPrimaryDark">@color/primary_dark</item> </style> 
+5
source share
3 answers

Each activity needs to expand ActionBarActivity. AppCompat does not use the built-in toolbar or ActionBar, even on Lollipop.

See http://android-developers.blogspot.com/2014/10/appcompat-v21-material-design-for-pre.html for details

+1
source

Your activity should be expanded by ActionBarActivity . You can use special style v21.

If your style extends Theme.AppCompat or Theme.AppCompat.Light , a default action bar should automatically appear. If the style continues ...NoActionBar , you must specify it in the layout, as in pure LOLLIPOP . The second will give you finer control over the theme of the toolbar.

+1
source

try this one

 <style name="FamilyDashboardTheme" parent="Theme.AppCompat.Light.NoActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/familycolor</item> <item name="colorPrimaryDark">@color/familydarkcolor</item> <item name="colorAccent">@color/familycolor</item> <item name="android:textColorPrimary">@android:color/white</item> <item name="android:windowBackground">@android:color/white</item> </style> 
-1
source

Source: https://habr.com/ru/post/1208179/


All Articles