Material Design Android - Rodrigo Garcete

21
Material Design Android Rodrigo Garcete Software Developer Manager GDG Ciudad del Este

Transcript of Material Design Android - Rodrigo Garcete

Page 1: Material Design Android - Rodrigo Garcete

Material Design Android

Rodrigo Garcete

Software Developer

Manager GDG Ciudad del Este

Page 2: Material Design Android - Rodrigo Garcete

Que es Material Design

Page 3: Material Design Android - Rodrigo Garcete

Que es Material Design

Page 4: Material Design Android - Rodrigo Garcete

Material Palette

http://www.materialpalette.com

Page 5: Material Design Android - Rodrigo Garcete

Add dependency

archivo build.gradle

dependencies {compile fileTree(include: ['*.jar'], dir: 'libs')compile ‘com.android.support:appcompat-v7:21.0.3’

}

Page 6: Material Design Android - Rodrigo Garcete

Set your primary colors

archivo colors.xml

<resources> <color name="primary_color">#F44336</color> <color name="primary_dark_color">#D32F2F</color> <color name="accent_color">#FFC107</color></resources>

Page 7: Material Design Android - Rodrigo Garcete

Make you theme extend AppCompat

archivo styles.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <item name="colorPrimary">@colors/primary_color</item> <item name="colorPrimaryDark">@colors/primary_dark_color</item> <item name="colorAccent">@colors/accent_color</item></style>

Page 8: Material Design Android - Rodrigo Garcete

Toolbar

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

Page 9: Material Design Android - Rodrigo Garcete

Add Toolbar to layouts

<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="@color/primary_color" android:minHeight="?attr/actionBarSize" app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" app:popupTheme="@style/ThemeOverlay.AppCompat.Light">

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

Page 10: Material Design Android - Rodrigo Garcete

App Bar

Page 11: Material Design Android - Rodrigo Garcete

TabLayout

<android.support.design.widget.TabLayout android:id="@+id/sliding_tabs" android:layout_width="match_parent" android:layout_height="wrap_content" app:tabMode="fixed" app:tabGravity="fill" />

tabMode - This sets the mode to use for the TabLayout. This can either be fixed (all tabs are shown concurrently) or scrollable (show a subset of tabs that can be scrolled through)

tabGravity: - This sets the Gravity of the tabs, which can be either fill(distribute all available space between individual tabs) or centre(position tabs in the center of the TabLayout)

setText(): This method is used to set the text to be displayed on the tab

setIcon(): This method is used to set the icon to be displayed on the tab

Page 12: Material Design Android - Rodrigo Garcete

Floating Action Buttons

<android.support.design.widget.FloatingActionButton android:id=”@+id/fab_normal” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:src=”@drawable/ic_plus” app:fabSize=”normal” />

Page 13: Material Design Android - Rodrigo Garcete

Navigation View

The new NavigationView component can simply be placed within our DrawerLayout (see code example below) and display our navigation items from the referenced menu resource.

Page 14: Material Design Android - Rodrigo Garcete

Navigation View Metricas

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true">

<FrameLayout android:id="@+id/main_content_frame" android:layout_width="match_parent" android:layout_height="match_parent" />

<android.support.design.widget.NavigationView android:id="@+id/navigation_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" app:headerLayout="@layout/navigation_header" app:menu="@menu/drawer" />

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

Page 15: Material Design Android - Rodrigo Garcete

EditText Floating Label

<android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content">

<EditText android:id="@+id/edit_text_email" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="textEmailAddress" android:hint="@string/hint_email" />

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

setErrorEnabled(true);setError(getString(R.string.text_error_message));

Page 16: Material Design Android - Rodrigo Garcete

SnackBar

Snackbar.make(mDrawerLayout, "YOUR MESSAGE", Snackbar.LENGTH_SHORT) .setAction(getString(R.string.text_undo), this) .show();

Page 17: Material Design Android - Rodrigo Garcete

Coordinator Layout

The CoordinatorLayout builds on-top of the motion effects already provided by adding the ability to transition views based on the motion of others

archivo build.gradle

dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') compile ‘com.android.support:appcompat-v7:21.0.3’ compile ‘com.android.support:design:21.0.3’

}

Page 18: Material Design Android - Rodrigo Garcete

Coordinator Layout with Collapsing Toolbar

<android.support.design.widget.CoordinatorLayoutandroid:id="@+id/main_content">

<!-- Your other views --!>

<android.support.design.widget.FloatingActionButton

android:id=”@+id/fab_normal” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:src=”@drawable/ic_plus” android:layout_gravity="bottom|right" app:fabSize=”normal” />

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

Page 19: Material Design Android - Rodrigo Garcete

RecyclerView

archivo build.gradle

dependencies {compile fileTree(include: ['*.jar'], dir: 'libs')compile ‘com.android.support:appcompat-

v7:21.0.3’

compile ‘com.android.support:recyclerview-v7:21.0.3’}

Page 20: Material Design Android - Rodrigo Garcete

CardView

archivo build.gradle

dependencies {compile fileTree(include: ['*.jar'], dir: 'libs')compile ‘com.android.support:appcompat-

v7:21.0.3’

compile ‘com.android.support:cardview-v7:21.0.3’}

Page 21: Material Design Android - Rodrigo Garcete

Resources

https://material.google.com

http://www.materialup.com/

https://labs.ribot.co.uk/exploring-the-new-android-design-support-library-b7cda56d2c32#.ss90ney07

http://antonioleiva.com/materialize-app/

http://www.materialpalette.com/