Android material design lecture #2

144
https://goo.gl/forms/xWbhO ultl5GDLDzS2

Transcript of Android material design lecture #2

Page 1: Android material design   lecture #2

https://goo.gl/forms/xWbhOultl5GDLDzS2

Page 2: Android material design   lecture #2

Designers Developers

Page 3: Android material design   lecture #2

pUp3EkaP

Page 4: Android material design   lecture #2

First,

Page 5: Android material design   lecture #2

Yarkoni

IronSource

Android Academy

Page 6: Android material design   lecture #2

~ 2000 members Largest Android Active Community

Page 7: Android material design   lecture #2

Jonathan Yarkoni

Android Leader Ironsource

Android Academy Staff

Yonatan Levin

Android Google Developer

Expert

Britt Barak

Android LeadFigure8

Yossi Segev

Android DeveloperColu

Shahar Avigezer

Android DeveloperHello Heart

Page 8: Android material design   lecture #2

Community Mentors

Page 9: Android material design   lecture #2

What Do We Do?

●Android Fundamentals - Done

● Android UI / UX - 29/1 !

● Community Hackathon - 9/3 !!!

●Android Performance

●Mentors Program

●Active community

Page 10: Android material design   lecture #2

Best business card

Page 11: Android material design   lecture #2

J. Yarkoni05/02/2017

Material Design Concepts & Implementation

1

Page 12: Android material design   lecture #2

What’s For Today?

Material Design

Concepts

Properties

Components

● Navigation

● Notifications

Page 13: Android material design   lecture #2

Over 1 million apps on the store

We want you to publish your app.

1 in 3 new apps is released as material!

Page 14: Android material design   lecture #2

Recap - Basic Components

FrameLayout

LinearLayout

RelativeLayout

GridView

RecyclerView (ListView)

Page 15: Android material design   lecture #2

What is Material?

Page 16: Android material design   lecture #2

We challenged ourselves to create a visual language

for our users that synthesizes the classic

principles of good design with the innovation and

possibility of technology and science - This is

material design.

Page 17: Android material design   lecture #2

Inspiration

Page 18: Android material design   lecture #2

Why Material?

Page 19: Android material design   lecture #2

Material Design

- Started as a functional bare necessity framework.

- Now it is time to pay attention to the details.

Page 20: Android material design   lecture #2
Page 21: Android material design   lecture #2

Material Design

Not a set of rules.

A set of guidelines

Very detailed, not very restrictive

Cross platform.

https://www.google.com/design/spec/material-design/

Page 22: Android material design   lecture #2
Page 23: Android material design   lecture #2
Page 24: Android material design   lecture #2

Material design principles

Metaphor - unifying theory of rationalized space and system

of motion.

Page 25: Android material design   lecture #2
Page 26: Android material design   lecture #2

Surfaces

Mobile is a medium for delivering content.

We need a container for content.

Page 27: Android material design   lecture #2

From the Real World

Page 28: Android material design   lecture #2
Page 29: Android material design   lecture #2

Properties

Page 30: Android material design   lecture #2

Paper & Ink - real world

Paper is a simple shape

Paper is colorless

Paper is constrained by the Z depth

Paper Flat never tiltted never flips over

Every pixel is a dot

Ink is restricted by the paper

Page 31: Android material design   lecture #2
Page 32: Android material design   lecture #2

Translating Paper into Device

3D world

Each layer 1 dp thickness.

Conveys relevance.

Create a consistent

illusion.

Page 33: Android material design   lecture #2

Paper & Ink

Page 34: Android material design   lecture #2

Paper & Ink

Page 35: Android material design   lecture #2

Paper & Ink

Page 36: Android material design   lecture #2

Paper & Ink

Page 37: Android material design   lecture #2

Paper & Ink

Page 38: Android material design   lecture #2

Shadows

Page 39: Android material design   lecture #2

Shadows

Page 40: Android material design   lecture #2

Perceived depth

Page 41: Android material design   lecture #2

build.gradle

<android.support.v7.widget.Toolbar

android:id="@+id/toolbar"

android:layout_width="match_parent"

android:layout_height="?attr/actionBarSize"

android:background="?attr/colorPrimary"

android:elevation="4dp" />

Page 42: Android material design   lecture #2

build.gradle

<android.support.v7.widget.Toolbar

android:id="@+id/toolbar"

android:layout_width="match_parent"

android:layout_height="?attr/actionBarSize"

android:background="?attr/colorPrimary"

android:elevation="8dp" />

Page 43: Android material design   lecture #2

build.gradle

<android.support.v7.widget.Toolbar

android:id="@+id/toolbar"

android:layout_width="match_parent"

android:layout_height="?attr/actionBarSize"

android:background="?attr/colorPrimary"

android:elevation="16dp" />

Page 44: Android material design   lecture #2
Page 45: Android material design   lecture #2
Page 46: Android material design   lecture #2

Elevation

Page 47: Android material design   lecture #2

Paper & Ink

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

android-

Page 48: Android material design   lecture #2

Shadow & Lighting - example

Depth of the phone

Page 49: Android material design   lecture #2

Shadow & Lighting - example

Depth of the phone

Page 50: Android material design   lecture #2

Surfaces - In practice

Page 51: Android material design   lecture #2

Surfaces - food for thought

Page 52: Android material design   lecture #2

Material design principles

Bold, Graphic & Intentional - immerse the user in the

experience.

Dictionary - not hesitating to break the rules of the state or quality of conforming to conventionally accepted standards of behavior or morals.

Page 53: Android material design   lecture #2

Typography

Page 54: Android material design   lecture #2

BoldTypography

Page 55: Android material design   lecture #2

Color

Page 56: Android material design   lecture #2

Color Hierarchy

Page 57: Android material design   lecture #2

Color Palette - example

Page 58: Android material design   lecture #2

Color Palette

●TIP : 2-3 hues of primary + 1 accent color

Page 59: Android material design   lecture #2

Palette Class

Extracting palette from image

Page 60: Android material design   lecture #2

Material design principles

Motion provides meaning - respect the user as the prime

mover.

Page 61: Android material design   lecture #2

Should feel natural

Page 63: Android material design   lecture #2
Page 64: Android material design   lecture #2

Animations Are Important

●Draws the eye.

● Instruct user.

●Continuous experience.

●Delightful details.

●User feedback.

Page 65: Android material design   lecture #2

Continuous Experience

Relations between screens

Shared elements.

Activity transitions.

Page 66: Android material design   lecture #2

Respect the user

Page 67: Android material design   lecture #2

Triggers & touch feedback

●Targets size : 48dp (7-9mm)

● Feedback for ALL touchable elements

○ standard button

○ Ripples

○ Selectors

Page 68: Android material design   lecture #2
Page 69: Android material design   lecture #2
Page 70: Android material design   lecture #2

Guidelines

Page 71: Android material design   lecture #2

The App Should Guide the User

Page 72: Android material design   lecture #2

Components

Cards

Toolbar

Appbar

Tabs

Navigation drawer

Snack bar

CoordinatorLayout

Page 73: Android material design   lecture #2

activity_main.xml

<android.support.v7.widget.CardView

xmlns:card_view="http://schemas.android.com/apk/res-auto"

android:id="@+id/card_view"

android:layout_gravity="center"

android:layout_width="200dp"

android:layout_height="200dp"

card_view:cardCornerRadius="4dp">

<!-- Insert Content -->

</android.support.v7.widget.CardView>

Page 74: Android material design   lecture #2
Page 75: Android material design   lecture #2
Page 76: Android material design   lecture #2
Page 77: Android material design   lecture #2

activity_main.xml

<android.support.design.widget.AppBarLayout

android:layout_height="wrap_content"

android:layout_width="match_parent"

android:theme="@style/AppTheme.AppBarOverlay">

<android.support.v7.widget.Toolbar

android:id="@+id/toolbar"

android:layout_width="match_parent"

android:layout_height="?attr/actionBarSize"

android:background="?attr/colorPrimary"

app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>

Page 78: Android material design   lecture #2
Page 79: Android material design   lecture #2

activity_main.xml

<android.support.design.widget.AppBarLayout

android:layout_height="wrap_content"

android:layout_width="match_parent"

android:theme="@style/AppTheme.AppBarOverlay">

<android.support.v7.widget.Toolbar

android:id="@+id/toolbar"

android:layout_width="match_parent"

android:layout_height="?attr/actionBarSize"

android:background="?attr/colorPrimary"

app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>

Page 80: Android material design   lecture #2
Page 81: Android material design   lecture #2
Page 82: Android material design   lecture #2
Page 83: Android material design   lecture #2

activity_main.xml

<android.support.design.widget.AppBarLayout

android:layout_height="160dp"

android:layout_width="match_parent"

android:theme="@style/AppTheme.AppBarOverlay">

<android.support.v7.widget.Toolbar

android:id="@+id/toolbar"

android:layout_width="match_parent"

android:layout_height="?attr/actionBarSize"

android:background="?attr/colorPrimary"

app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>

Page 84: Android material design   lecture #2
Page 85: Android material design   lecture #2
Page 86: Android material design   lecture #2

Supports both fixed and scrollable.

Page 87: Android material design   lecture #2

Supports both fixed and scrollable.

Page 88: Android material design   lecture #2

activity_main.xml

<android.support.design.widget.TabLayout

android:id="@+id/sliding_tabs"

android:layout_width="match_parent"

android:layout_height="wrap_content"

app:tabMode="scrollable"/>

Page 89: Android material design   lecture #2

activity_main.xml

<android.support.design.widget.TabLayout

android:id="@+id/sliding_tabs"

android:layout_width="match_parent"

android:layout_height="wrap_content"

app:tabMode="fixed"/>

Page 90: Android material design   lecture #2
Page 91: Android material design   lecture #2
Page 92: Android material design   lecture #2
Page 93: Android material design   lecture #2
Page 94: Android material design   lecture #2
Page 95: Android material design   lecture #2

activity_main.xml

<android.support.v4.widget.DrawerLayout

xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:app="http://schemas.android.com/apk/res-auto"

xmlns:tools="http://schemas.android.com/tools"

android:id="@+id/drawer_layout"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:fitsSystemWindows="true"

tools:openDrawer="start">

<android.support.design.widget.NavigationView

android:id="@+id/nav_view"

android:layout_width="wrap_content"

android:layout_height="match_parent"

android:layout_gravity="start"

android:fitsSystemWindows="true"

app:headerLayout="@layout/nav_header_main"

app:menu="@menu/activity_main_drawer" />

</android.support.v4.widget.DrawerLayout>

Page 96: Android material design   lecture #2

nav_header_main.xml

<LinearLayout ...>

<ImageView

android:id="@+id/imageView"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:background="@color/colorPrimary"

android:paddingTop="@dimen/nav_header_vertical_spacing"

android:src="@android:drawable/sym_def_app_icon"/>

<TextView

...

android:text="NavDrawer"

android:textAppearance="@style/TextAppearance.AppCompat.Body1"/>

<TextView

...

android:text="example"/>

</LinearLayout>

Page 97: Android material design   lecture #2

activity_main_drawer.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android">

<group android:checkableBehavior="single">

<item

android:id="@+id/nav_camera"

android:icon="@drawable/ic_menu_camera"

android:title="Import" />

<item

android:id="@+id/nav_gallery"

android:icon="@drawable/ic_menu_gallery"

android:title="Gallery" />

...

</group>

...

</menu>

Page 98: Android material design   lecture #2
Page 99: Android material design   lecture #2

activity_main.xml

<android.support.design.widget.AppBarLayout ...>

<android.support.design.widget.CollapsingToolbarLayout

android:id="@+id/toolbar_layout"

android:fitsSystemWindows="true"

android:layout_width="match_parent"

android:layout_height="match_parent"

app:layout_scrollFlags="scroll|exitUntilCollapsed"

app:contentScrim="?attr/colorPrimary">

<android.support.v7.widget.Toolbar .../>

</android.support.design.widget.CollapsingToolbarLayout>

</android.support.design.widget.AppBarLayout>

Page 100: Android material design   lecture #2

activity_main.xml

<android.support.v4.widget.NestedScrollView

xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

xmlns:app="http://schemas.android.com/apk/res-auto"

app:layout_behavior="@string/appbar_scrolling_view_behavior"

tools:showIn="@layout/activity_scrolling"

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context="com.ironsource.collapsingtoolbar.ScrollingActivity">

<TextView ... />

</android.support.v4.widget.NestedScrollView>

Page 101: Android material design   lecture #2
Page 102: Android material design   lecture #2
Page 103: Android material design   lecture #2

FAB do’s and don’ts

Page 104: Android material design   lecture #2

FAB do’s and don’ts

Page 105: Android material design   lecture #2
Page 106: Android material design   lecture #2
Page 107: Android material design   lecture #2
Page 108: Android material design   lecture #2
Page 109: Android material design   lecture #2

activity_main.xml

<android.support.design.widget.FloatingActionButton

android:id="@+id/fab"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="bottom|end"

android:layout_margin="@dimen/fab_margin"

android:src="@android:drawable/ic_dialog_dialer"/>

Page 110: Android material design   lecture #2

MainActivity.xml

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);

fab.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH)

.setAction("Action", null)

.show();

}

});

Page 111: Android material design   lecture #2

FAB - floating action button

FAB can morph.

FAB can move.

Page 112: Android material design   lecture #2
Page 113: Android material design   lecture #2
Page 114: Android material design   lecture #2
Page 115: Android material design   lecture #2
Page 116: Android material design   lecture #2

MainActivity.xml

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);

fab.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH)

.setAction("Action", null)

.show();

}

});

Page 117: Android material design   lecture #2

~TOASTS~

Page 118: Android material design   lecture #2

snackbar

Dialogs

interruptive.

2 actions at max.

use for critical moments.

Toasts

Easily overlooked.

no actions.

use for simple alerts.

Page 119: Android material design   lecture #2

snackbar

One action.

Use for aiding the user and giving information.

Unpanic~!

Page 120: Android material design   lecture #2
Page 121: Android material design   lecture #2

What if I develop for older versions?

Page 122: Android material design   lecture #2

The Android Support Library package is a set of code

libraries that provide backward-compatible versions of

Android framework APIs as well as features that are only

available through the library APIs.

Page 123: Android material design   lecture #2

Android Support Library

Set of code libraries (function).

Provide back-wards compatibility for older versions.

Provide new features.

Page 124: Android material design   lecture #2

Android Support Library

Set of code libraries (function).

Released Independently.

Provide back-wards compatibility for older versions.

Provide new features.

Page 125: Android material design   lecture #2

build.gradle

dependencies {

compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'com.android.support:appcompat-v7:23.1.1'

compile 'com.android.support:design:23.1.1'

}

Page 126: Android material design   lecture #2

Navigation

Page 127: Android material design   lecture #2
Page 128: Android material design   lecture #2

Navigation

BackStack.

Back vs. Home

Activity A

Activity B

Activity C

Page 131: Android material design   lecture #2

Notifications

Types

Status bar.

Heads up.

LockScreen.

Expandable.

Actions.

Page 132: Android material design   lecture #2

Status bar

Page 133: Android material design   lecture #2

Heads up

Page 134: Android material design   lecture #2

Lockscreen

Page 135: Android material design   lecture #2

Expandable

Page 136: Android material design   lecture #2

Actions

Page 137: Android material design   lecture #2

MainActivity.java

Intent resultIntent = new Intent(this, MainActivity.class);

PendingIntent resultPendingIntent = PendingIntent.getActivity(this, 0,

resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);

Page 138: Android material design   lecture #2

MainActivity.java

NotificationCompat.Builder mBuilder = new

NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_menu_camera)

.setContentTitle("My notification")

.setContentText("Hello World!")

.setContentIntent(resultPendingIntent);

Page 139: Android material design   lecture #2

MainActivity.java

int mNotificationId = 001;

NotificationManager mNotifyMgr = (NotificationManager)

getSystemService(NOTIFICATION_SERVICE);

mNotifyMgr.notify(mNotificationId, mBuilder.build());

Page 140: Android material design   lecture #2

34th floor

Page 141: Android material design   lecture #2

Drive home safe

See you next Tuesday!

Page 142: Android material design   lecture #2

Hackathon

Page 143: Android material design   lecture #2

Designers Developers

Page 144: Android material design   lecture #2

https://goo.gl/forms/xWbhOultl5GDLDzS2