09 material design

  • View
    82

  • Download
    0

  • Category

    Travel

Preview:

Citation preview

Material DesignAnuchit Chalothornanoochit@gmail.com

Material Design for Android

Material design is a comprehensive guide for visual, motion, and interaction design across platforms and devices. See more in https://material.io/guidelines

Elements

● New Theme ● New Widget eg: RecyclerView, CardView, Snackbar● New API for custom shadow, animation

Material Design Template

Mobile Layout

Tablet Layout

Desktop Layout

Vertical Divider & Horizontal Divider

Cardview & Breaking and edge with FAB

Material Design Theme

Use Material Design Palette to create your own theme

https://www.materialpalette.com

<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>

Codelab: Fragment replace

Start new project with navigation view, insert FrameLayout as a container, prepare for replace with FragmentActivity

Fragment replace

MainFragment fragment = new MainFragment();

FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();

fragmentTransaction.replace(R.id.fragment_container,fragment);

fragmentTransaction.commit();

Recyclerview

Key concept to use RecyclerView

1. Add RecyclerView support library to the gradle build file2. Define a model class to use as the data source3. Add a RecyclerView to your activity to display the items4. Create a custom row layout XML file to visualize the item5. Create a RecyclerView.Adapter and ViewHolder to render the item6. Bind the adapter to the data source to populate the RecyclerView

Listview with recyclerview

Use itemDecoration and DividerItemDecoration to create space between items

Cardview

Cardview use as RecyclerView but can handle with different layout

● LinearLayoutManager● GridLayoutManager● StaggeredGridLayoutManager