Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Material Design AppCompat

I am new to Android Material Design Concept. I have created a new project and added material theme with AppCompat support for pre-lollipop versions but my problem is, in Lollipop it shows the ActionBar aka Toolbar but if i run the same in pre-lollipop it doesn't show the ActionBar.

Do i just need to use Toolbar control everywhere in my Layout regardless of API version?

Edited:

<!-- 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>
like image 577
Kirk Avatar asked Dec 02 '14 18:12

Kirk


People also ask

What is Material Design Android?

Material design is a comprehensive guide for visual, motion, and interaction design across platforms and devices. To use material design in your Android apps, follow the guidelines defined in the material design specification and use the new components and styles available in the material design support library.

How do I use Google Material Design in Figma?

To get started, visit the Material Design community page: In the Material Design 3 design kit, select Get a copy. You'll get a copy of the file, components, and styles to start using in Figma. Publish the file as a library to make the design kit available through the assets tab to you and your team.

Is Material Design a library?

Material Design is a comprehensive set of design guidelines that goes beyond a simple framework. Google's Material Design patterns could be considered a design library rather than a framework. It's one of the most comprehensive open-source libraries currently available.

What is colorPrimary and colorPrimaryVariant?

colorPrimary and colorSecondary represent the colors of your brand. colorPrimaryVariant and colorSecondaryVariant are lighter or darker shades of your brand colors. colorSurface is used for “sheets” of material (like cards and bottom sheets) android:colorBackground is the window background color of your app.


2 Answers

Every Activity needs to extend ActionBarActivity. AppCompat doesn't use the native Toolbar or ActionBar, even on Lollipop.

For more info see: http://android-developers.blogspot.com/2014/10/appcompat-v21-material-design-for-pre.html

like image 51
Jared Rummler Avatar answered Oct 02 '22 14:10

Jared Rummler


Your activity must extend ActionBarActivity. You can ditch the special v21 style.

If your style extends Theme.AppCompat or Theme.AppCompat.Light there should be a default action bar automatically. If the style extends ...NoActionBar you have to specify it in the layout like in pure LOLLIPOP. The second will give you finer control over the Toolbar theming.

like image 43
Eugen Pechanec Avatar answered Oct 02 '22 16:10

Eugen Pechanec