This Tutorial Android Material Design
Next App Tutorial Coding a Layerlist with Elevation
If you are just arriving at this page; and you are not familiar with with creating Android Apps, we suggest you begin with our tutorials:
Coding Android App Pages
and How To Create a Simple App in Android
From there follow along with each tutorial lesson.
AIDE and ANDROID STUDIO
We are using AIDE(a mobile coding environment using language java/xml), to create these tutorial apps on our
tablet(7" screen) that has android version 5.0.
Once we build and RUN our app; we then install the app on this same tablet; and the app is also installed on a smart phone that has android version 6.
AIDE can be installed on any android version from 4 - 8.
We are using the AIDE coding editor to code our pages; and then to Create - RUN our apps. AIDE is a SDK coding environment for android devices like a tablet or smartphone.
AIDE has a free and paid version.
Once you create your apps code pages, you need to RUN the app to build your apk package; then you INSTALL it on your tablet or smartphone.
For info on using AIDE, gohere
can also create; RUN your apps using the code in these tutorials, with Android Studio. Android Studio is for desktop computers. Choose Java XML as the programming language.
Android Studio is free to install and use for your android app development. Although not as convenient as testing your app on an actual android device; you can test
your newly created app in Android Studio using its' android emulator.
Complete Example Codes are available for each of our tutorials. With these example codes you can make a functioning android app in
either AIDE or Android Studio.
Android Material Design
Introduced in Android Version 5, API 21
Material Design is new code classes for developing android apps; included are:
New color blends for the UI interface;
Elevation for UI(user interface) elements;
The new material theme (light and dark);
Floating Action Button(FAB);
Drawable animation with styling effects;
Material design animation;
Activity transition effects;
Animators for view properties based on view states;
Customizable UI widgets and app bars with controllable color palettes;
Animated and non-animated drawables with XML vector graphics;
New widgets to create complex views;
New APIs to create custom shadows and animations.
First, create a java/xml android template app using AIDE, (or Android Studio). Then you can get the code for this app from the EXAMPLE CODE section on this page.
Replace the code on the pages you need to(with our tutorial code); in order to create this app.
Sometimes, new pages have to be created.
All the other coded pages in your app
can remain as they are; they don't need to be changed.
This is the App - Material Theme
It is the light theme of the material design theme; coded as material.theme.light; there is also a material.theme which is the dark color.
Where - How - Why To Use Material Design
Material Design introduces new coding methods to use in your android app development. Some codes and concepts are entirely new, while others build upon previous code classes making
them more functional and or improving their performance for your app.
Examples of this are the new RecyclerView and CardView widgets, which basically extend the capabilities of the previously known ListView.
For designing your UI; features include new functionality for fab buttons, the new ripple buttons and blended color charts; snacktoast messages, and elevated shadows for elements.
And for drawables and animations, there is now xml vector graphics, and drawable animations with styling effects.
Coding Themes - Holo and Material
For our app tutorial, we have added two themes, one for the new Material Theme theme light (light color version) and one for the holo theme light (also light in color).
We have added both so that users with devices using the newer android platforms 5 and greater, will be shown the Material Theme's light theme, and users on android
platforms less than version 5 will be shown the holo theme light theme. To code this in our app we must do this:
Create two styles.xml pages. They each have the same page name, that being: styles.xml. And, each page has exactly the same coding except for the theme names; Theme.Material.Light and Theme.Holo.Light.
Here are images showing the coding for each theme.
Theme Holo Light Code
Theme Material Light Code
To make each theme display accordingly to the android version being used we have to create a folder for the Material Theme, as such: res/values-v21, and put our
styles.xml coded page for the Material Theme into the values-v21 folder. The 21 in the folder name stands for API 21 because android version 5.1 is api 21.
The styles.xml page for the Holo.Theme.Light is put into the app's default res/values folder.
Once we have coded the styles.xml pages and put them in their folders, we need to add the style name we gave our theme to the the AndroidManifest.xml file. We
named it AppTheme
so just add that name to the manifest file code as such:
Now the android system will display each theme depending on the android platform being used.
Additional Reading at these websites:
Android Developer Website:
Material Design for Android
Designing Your App Using Material Design
Creating - Naming Your App Using AIDE
When creating your app,(from left menu) choose:
Create New Project;
New Android App(gradle, android Java/xml)
Hello World App Java/xml
if your using the original version of AIDE
You can name your app whatever you like; if your using the name as shown in our example code use;
for the App Name and,
for the package name(next line) use:
The Coded Pages
Code for the app - Material Theme
For this app you will use these coded pages:
1 layout file, main.xml; located at res/layout/main.xml, already created, just replace the code on this page with the code from our Example Code section and save the page.
1 java class page; MainActivity.java; located at app/src/java/MainActivity.java, already created; we don't need to add or edit code on this page so leave it as it is.
1 styles.xml for Theme.Holo.Light, already created when you created your android template app for this tutorial, located at res/values/styles.xml Since it's
already been created, you don't have to do anything to this page code.
1 styles.xml for Theme.Material.Light, already created for you when you created your android template app for this tutorial; at res/values-v21/styles.xml
If however, you needed to create it; do this:
First, create the folder, values-v21
at res/, then create the file styles.xml
; just copy paste the code from our example code into the page to replace the
code on page now, then save the page. Make sure to copy the Theme.Material.Light code.
Now you have your two styles.xml created. One for the holo theme and one for the material theme.
If a user with android version 5 or greater uses your app, then the Material Theme Light will display for them, and if a user on a android version less than 5 downloads
and uses your app, then the Holo Theme Light will display for them.
1 strings.xml file, for text on our app page; file created for you when you created your android template app; just replace code that's there with code from our Example Code and save page.
1 manifest file, AndroidManifest.xml (already created).
This is where you put the name of your theme, in this case the name given to it is AppTheme. This name is already in the androidmanfest.xml file, It was created for us when we created our
template android app, so we don't need to edit this page.
In this file you can also code your SDK min and target versions for your app. These can also be coded in the build.gradle file of your app project.
The important thing is that you code the version for the code your adding. In this app we are adding the material theme, from the Material Design coding classes; so we must use the SDK version for that code class which
is SDK target version 21. This has already been coded for us when the app was created for us, so we don't have to add the SDK version or edit the page.
The material theme light color is similar to the holo.theme.light, so using either of these themes will give your app page a light color view.
If you want to use a darker color for your view you can use Material.Theme, which will show a dark color.
As mentioned in our previous tutorial on themes, you can add them to the entire app, or to individual pages in your app.
The build.gradle. file is where you can define certain system requirements for your app; like coding your library support files;(dependencies); and your sdk min and target versions (especially important for material design compatibility).
As mentioned, because we created our app with an android template app the build.gradle file was created for us and the SDK target version 21 has been added to the Config code in the page.
The build.gradle is a file you will likely
use(code) more often as your gain experience coding android apps; especially if your adding Material Design code components to your apps; and want to make them
compatible across all the android platform versions.
We know we need to add the SDK target version 21 to our build.gradle or androidmanifest.file for Material Design coding classes. Additionally, we need to add
, also known as dependencies. Not every Material Design code class requires you to add a support library but many do.
These support libraries are added to the build.gradle file in your app project. Every app project you create with AIDE or Android Studio will have a build.gradle file.
Your app project actually has two build.gradle files; there's one we can edit and one we cannot edit.
The one we can edit and add our codes to is at src folder of your app project(in AIDE):
at AppProjects/MaterialTheme/app/ and is named build.gradle. The other one has a header text saying 'DO NOT EDIT THIS FILE'
We have included in our EXAMPLE Code section; the build.gradle file from this tutorial so you can see what the code in the file
You can read additional info at the android developer website
To add a library for a code class your adding to your app; you need to add a few lines of code, to the build.gradle file at the section named
And, for any Material Design code classes, you also need to add the SDK version 21 as the target version in the androidmanifest.xml or build.gradle file.
We will discuss the build.gradle file in another tutorial when we add some libraries.
Although you can add general libraries which cover more than one code class; it is recommended to only add the code class for the actual components your going to use in your app.
the apk(your app package file) does not contain unnecessary files.
These links from android developer website have more info you can read on adding library support for Material Design and the various libraries available that you
Support Library Packages
Support Library Features Guide
Also Read:Maintaining Compatibility Across Platforms
The Build Process
At this time, (May 2019)users of the various android platform versions are varied. Looking at this 'Platform Distribution Chart', you can see that android versions 5.1 to 8 are the most
used platforms. They have about a 75% market share of android users. The most used platform as of May 2019 is version 6 with 21% of android users.
Chart of android platform distribution