what’s new for android developers in 2015 - material design, android studio, gradle

24
KAMAL K KISHORE 29-Apr-2015 & What’s new in

Upload: deepu-s-nath

Post on 17-Jul-2015

168 views

Category:

Technology


4 download

TRANSCRIPT

KAMAL K KISHORE

29-Apr-2015

&

What’s new in

Material Design

Material Theme

• @android:style/Theme.Material (dark version)

• @android:style/Theme.Material.Light (light version)

• @android:style/Theme.Material.Light.DarkActionBar

Customizing

• colorPrimary

• textColorPrimary

• colorPrimaryDark

• windowBackground

• navigationBarColor

Customizing<?xml version="1.0" encoding="UTF-8"?>

<resources>

<!-- inherit from the material theme -->

<style name="AppTheme" parent="android:Theme.Material“>

<!-- Main theme colors --> <!-- your app branding color for the

app bar -->

<item name="android:colorPrimary">@color/primary</item>

<!-- darker variant for the status bar and contextual app bars

<item

name="android:colorPrimaryDark">@color/primary_dark</item>

<!-- theme UI controls like checkboxes and text fields

<item name="android:colorAccent">@color/accent</item>

</style>

</resources>

• A different theme

• New widgets for complex views

• New API’s for Custom shadows and

animations

Elements of Material Design

Lists <!-- A RecyclerView with some

commonly used attributes -->

<android.support.v7.widget.RecyclerVie

w

android:id="@+id/my_recycler_view“

android:scrollbars="vertical“

android:layout_width="match_parent"

android:layout_height="match_parent"/

>

public class MyAdapter extends

RecyclerView.Adapter<MyAdapter.ViewH

older>

dependencies {

compile

'com.android.support:recyclerview-

v7:21.0.+‘ }

Cards <android.support.v7.widget.CardView

xmlns:card_view="http://schemas.andr

oid.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">

card_view:cardCornerRadius

card_view:cardBackgroundColor

dependencies {

compile

'com.android.support:cardview-

v7:21.0.+'

}

View Shadows• The Z property

– android:elevation attribute

Clip Views• Transforming shape of a view

– android:clipToOutline

Animations

Vector Drawables

• Drawable tinting

– android:tint

– android:tintMode

• Prominent color extraction

– Palette.getVibrantColor

• Vector drawables

– <vector >

– <path android:fillColor="#8fff"

– android:pathData=….

– </vector >

Defining Custom Animations• Touch feedback

• Circular Reveal

• Activity transitions

• Curved motion

• View state changes

Reveal Effect

• create the animator for this view (the

start radius is zero)

• Animator anim =

ViewAnimationUtils.createCircularRev

eal(myView, cx, cy, 0, finalRadius);

• make the view visible and start the

animation

• myView.setVisibility(View.VISIBLE);

• anim.start();

Compatibility

• Using styles

– Define a theme that inherits from an older

theme (like Holo) in res/values/styles.xml.

– Define a theme with the same name that

inherits from the material theme in

res/values-v21/styles.xml.

– Set this theme as your app's theme in the

manifest file.

Compatibility• Using layouts

– res/layout-v21/

– res/layout/

• Using Support Library v7-21

– Some system widgets when you apply one of

the Theme.AppCompat themes.

– Color palette theme attributes in the

Theme.AppCompat themes.

– The RecyclerView widget to display data

collections.

– The CardView widget to create cards.

– The Palette class to extract prominent colors

from images.

google.com/design

What is Gradle?

• Gradle is an advanced build toolkit that

manages dependencies and allows you to

define custom build logic.

• This means that you can build your Android

apps from which Android Studio and from the

command line on your machine or on

machines where Android Studio is not

installed.

• The build files are called build.gradle, and

they are plain text files that

use Groovy syntax

Why Gradle?

• The Gradle build system is designed to

support complex scenarios in creating

Android applications.

– Multi-distribution: the same application must

be customized for several clients or companies

– Multi-apk: supporting the creation of multiple

apk for different device types while reusing

parts of the the code

Using Gradle to build different variants

• applying plugin

– apply plugin: 'com.android.application‘

• setting defaultConfig

– applicationId, minSdkVersion,

targetSdkVersion, versionCode,

versionName

• setting buildTypes

– proguardFiles, minifyEnabled

Using Gradle to build different variants

• adding productFlavors– sets applicationId & versionName for different

flavors (like paid, free etc.)

• adding dependencies– Module dependency - compile project(":lib")

– Remote binary dependency - compile

'com.android.support:appcompat-v7:19.0.1'

– Local binary dependency - compile fileTree(dir:

'libs', include: ['*.jar'])

gradle.org

Thank you