Wednesday, July 6

Material Design course : Android

Started a new course 'Material design for Android Developers'.
https://classroom.udacity.com/courses/ud862/lessons/4222899149/concepts/47897886270923

Material Design is a design language developed in 2014 by Google. 
Google states that their new design language is based on paper and ink. 
Google announced Material Design on June 25, 2014, at the 2014 Google I/O conference.
https://material.google.com/

Lesson-1 Android Design Fundamentals

Density independent pixels (dip/dp)
formula:
no. of pixels / dp = pixel density / 160

Density Buckets
MDPI 160
HDPI 240
XHDPI 320
XXHDPI 480

Resource Qualifiers
https://developer.android.com/guide/topics/resources/providing-resources.html

Core Layout Managers:
1. FrameLayout
- arranges the views inside it, one on top of each other.
- a FrameLayout is a great way to display overlapping content.

2. LinearLayout
- arranges its children in a single direction.

3. RelativeLayout
- arranges its child views relative to each other or to its bounds.

4. GridLayout
- arranges its children in a grid, where each child has a given row or column within that grid.

5. ScrollView
- is a very simple view which holds one single child and allows you to scroll its contents up or down.

6. ListView and RecyclerView
- let you scroll through a list of items.

7. ViewPager
- lets you horizontally page through individual items.

Common Design Patterns:
1. Toolbar
- It's a ViewGroup that can be placed anywhere in your XML layouts.
2. App bar (formerly called action bar)
- The app bar is just a special case of the toolbar.
- The app bar often uses an extended height to provide more space for branding or to contain an image.

3. Tabs
- Generally they sit on the same surface as your app bar if you are using one.

4. Navigation drawer
- It is a panel that slides from the left of the scree, and it contains top-level navigation options to different parts of you application.

5. Scrolling (vertical) and Paging (horizontal)

6. List to details

7. Multi-pane

https://material.google.com/layout/structure.html#structure-system-bars

Themes and Styles:

A Style changes the appearance of a single UI element.

A Theme uses the same syntax as a style but applies a collection of styles to an element, an activity or even your whole application.

Styles always operate on a single element whereas Themes cascade to its children.

https://developer.android.com/guide/topics/resources/available-resources.html#stylesandthemes

Lesson-2 Surfaces

(Sheets of Digital Paper)

A surface is a container for our content and provides grouping and separation from other elements.

Elevation
android:elevation = "4dp"
The elevation is the distance a surface is above the back pane.
Higher values produce larger shadows.

https://material.google.com/what-is-material/elevation-shadows.html#

Floating Action Button (FAB)

Surface Reaction:
Visual feedback in response to touch.
1. Subtle Ripple Effect
2. Surface lift

Responding to scroll events:

Materials can change width and height. They can also change elevation.

Seam to Step Transition

CoordinatorLayout
- helps co-ordinate behaviours across several kinds of views.

android:nestedScrollingEnabled = "true"

AppBarLayout
CollapsingToolbarLayout

Lesson-3 Bold Graphic Design

(Digital Ink)

1. Space

Grid

Keylines

2. Color

a. Primary Color
b. Accent Color

colors.xml
styles.xml

Applying a color palette:
Using the Material Theme
https://developer.android.com/training/material/theme.html

3. Type
(typography)

Roboto

sp - scale-independent pixels

Font metrics

Font --> Family, Weight, and Style

android:fontFamily
android:textStyle

a) Limit your font palette.
b) Try it on two or more devices.
c) Font fits the mood you're setting in the app.

4. Imagery

a) Convey information.
b) Personalize the experience of using your app.
c) Provide delight.

Types of imagery:
1) Photography
2) Illustration
3) Iconography

Circular Avatars
RoundedBitmapDrawable class

Lesson-4 Meaningful Motion

In Android 4.4 KitKat or API 19, Scenes and Transitions API was introduced.

The OS needs to do a couple of things:
1. capture the starting state and end state for every view in the Scene.
2. create an animator that will interpolate between the starting and end states.

TransitionManager
This class manages the set of transitions that fire when there is a change of Scene.
The default transition for TransitionManager is AutoTransition.
  The SDK comes with a bunch of pre-fabricated transitions:
1. explode - Moves views in or out from the center of the scene.
2. slide - Moves views in or out from one of the edges of the scene.
3. fade - Adds or removes a view from the scene by changing its opacity.
4. changeBounds - Animates the changes in layout bounds of target views.
5. changeClipBounds - Animates the changes in clip bounds of target views.
6. changeTransform - Animates the changes in scale and rotation of target views.
7. changeImageTransform - Animates changes in size and scale of target images.

https://developer.android.com/training/material/animations.html

Scenes and Transitions API made it much easier to define how UI elements should move together.
The API allows you to define different states for your UI called Scenes. And also lets you define ways to Transition between those Scenes co-ordinating several UI elements at once.
You have two layouts that describe the two Scenes.
scene1.xml
scene2.xml

The Animation capabilities in Android have been evolving.

Android and Fragment Transitions
Android 5.0 Lollipop or API 21 added new ways to better choreograph moving between activities.

Activity Transitions:
1. content transition
2. shared element transition (visual continuity for shared elements across the two activities.)

Activity content transitions:
These transitions allow you to animate the views within an activity when they enter or leave it.
Activity A  --> Activity B
exit A               enter B

res/transition/grid_exit.xml
<explode xmlns... />
(built-in explode transition)

To assign the exit transition to the activity, we'll open the activity's theme and add an entry for windowExitTransition which points to the transition we just defined.
res/values/styles.xml

code vs. xml ?
harder to use the transition in other places
good separation of concerns.

In addition, you are also able to specify re-enter and return transitions.
return B              re-enter A

Shared element transitions:
1. We need to designate which views are shared.
We do this by setting the same Transition name attribute on the views in both activities.
android:transitionName=" "
2. ActivityOptions.makeSceneTransitionAnimation

Instructive Motion
-How something moves can give you plenty of hints about how you can interact with it.

How long animations should run for?
~300ms (milliseconds)

user-initiated change

The Interpolator interface:
An interpolator defines the rate of change of an animation.
This allows the basic animation effects (alpha, scale, translate, rotate) to be accelerated, decelerated, repeated, etc.

Coordinated Motion:

AnimatedVectorDrawables:

1. Create two vector drawables
res/drawable/ic_tick.xml
re/drawable/ic_cross.xml

<vector xmlns...
/>

2. Create animators for each of the steps that are changing
res/animator/cross_to_tick.xml

<objectAnimator
        xmlns...
/>

3. Create an animated vector drawable which connects the image to the animator

<animated-vector
/>

4. AnimatedVectorDrawable crossToTick = ... ;
crossToTick.start();

Lesson-5 Adaptive Design

At what points do you want to begin adapting your UI?

The basic idea of adaptive design is that you change your UI based on the screen size. That is, your UI adapts to the amount of vertical or horizontal space that you have.

We do this by what we call breakpoints.

Breakpoints
- are the points at which your UI changes.

Material spec identifies some common breakpoints.

Its important to think Content First.
You can then think of the breakpoints as the point at which your UI literally breaks for the content its trying to present.

Choosing breakpoints based on content requirements is more future-proof than basing them on a specific set of devices.
You'll know those requirements will be satisfied no matter what devices get thrown your way.

Implementing breakpoints-
Resource Qualifiers:
language
device orientation
screen size
layout/
layout-w600dp/

Techniques for managing space:
1. Reveal
2. Divide
3. Reflow
4. Expand

No comments:

Post a Comment