Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Android Support Library v23.2.0

Android Support Library v23.2.0

O google lançou uma atualização da sua Support Library pro Android. Nessa apresentação, veremos quais as principais novidades e como implementa-las

Rodrigo Sicarelli

March 02, 2016
Tweet

More Decks by Rodrigo Sicarelli

Other Decks in Technology

Transcript

  1. v23.2.0 - Vector Drawables and Animated Vector Drawables; - AppCompat

    DayNight theme; - Bottom Sheets Views and Dialogs; - MediaBrowserServiceCompat - RecyclerView: auto-measurement; - Chrome Custom Tabs; - Leanback for Android TV
  2. v23.2.0 - Vector Drawables and Animated Vector Drawables; - AppCompat

    DayNight theme; - Bottom Sheets Views and Dialogs; - MediaBrowserServiceCompat - RecyclerView: auto-measurement; - Chrome Custom Tabs; - Leanback for Android TV
  3. V23.2.0 - Vector Drawables and Animated Vector Drawables; - AppCompat

    DayNight theme; - Bottom Sheets Views and Dialogs;
  4. Lollipop - VectorDrawable "In Android 5.0 (API Level 21) and

    above, you can define vector drawables, which scale without losing definition. You need only one asset file for a vector image, as opposed to an asset file for each screen density in the case of bitmap images. To create a vector image, you define the details of the shape inside a <vector> XML element."
 
 developer.android.com/training/material/drawables.html
  5. Lollipop - VectorDrawable <svg fill="#000000" height="24" viewBox="0 0 24 24"

    width=“24"> <path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"/> <path d="M0 0h24v24H0z" fill="none"/> </svg> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp"> <path android:fillColor=“@color/someColor“ android:pathData="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z" /> <path android:fillColor=“@color/someColor“ android:pathData="M0 0h24v24H0z" /> </vector>
  6. support-vector-drawable // Gradle Plugin 2.0+ android { defaultConfig { vectorDrawables.useSupportLibrary

    = true } } // Gradle Plugin 1.5 android { defaultConfig { generatedDensities = [] } aaptOptions { additionalParameters "--no-version-vectors" } } dependencies { compile 'com.android.support:support-v4:23.2.0' compile 'com.android.support:appcompat-v7:23.2.0' }
  7. animated-support-vector-drawable <?xml version="1.0" encoding="utf-8"?> <vector xmlns:android="http://schemas.android.com/apk/res/android"> <group android:name="body"> <path> ...

    </path> </group> </vector> <?xml version="1.0" encoding="utf-8"?> <animated-vector xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/ic_android"> <target android:name="body" android:animation="@animator/translation" /> </animated-vector> <set xmlns:android="http://schemas.android.com/apk/res/android"> <objectAnimator android:duration="250" android:propertyName="translateY" android:repeatCount="infinite" android:repeatMode="reverse" android:valueFrom="0" android:valueTo="20" android:valueType="floatType" /> </set>
  8. animated-support-vector-drawable Drawable drawable = view.getDrawable(); if (drawable != null) {

    if (drawable instanceof Animatable) { ((Animatable) drawable).start(); } }
  9. V23.2.0 - Vector Drawables and Animated Vector Drawables; - AppCompat

    DayNight theme; - Bottom Sheets Views and Dialogs;
  10. AppCompat.DayNight <style name="MyTheme" parent="Theme.AppCompat.DayNight"> <!-- Blah blah --> </style> <style

    name="MyTheme" parent="Theme.AppCompat.DayNight.NoActionBar"> <!-- Blah blah --> </style> MODE_NIGHT_NO: Sempre usa o “day” (light) theme; MODE_NIGHT_YES. Sempre usa o “night” (dark) theme; MODE_NIGHT_AUTO. Altera para day/night de acordo com a hora do dia; MODE_NIGHT_FOLLOW_SYSTEM (default). Vai seguir a configuração do sistema, que basicamente é MODE_NIGH_NO;
  11. Habilitando public class ExampleApplication extends Application { @Override public void

    onCreate() { ... } static { AppCompatDelegate.setDefaultNightMode( AppCompatDelegate.MODE_NIGHT_AUTO); } } public class HomeActivity extends AppCompatActivity { public void changeDayNightTheme() { getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_YES); recreate(); } }
  12. V23.2.0 - Vector Drawables and Animated Vector Drawables; - AppCompat

    DayNight theme; - Bottom Sheets Views and Dialogs;
  13. Configurando public void init(){ View bottomSheet = coordinatorLayout.findViewById(R.id.bottom_sheet); bottomSheetBehavior =

    BottomSheetBehavior.from(bottomSheet); } private void showBottomSheetView() { bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); } private void collapseBottomSheetView() { bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); }
  14. Links úteis SVG’s design.google.com/icons DayNight post 
 goo.gl/AuqRAk Support vector

    drawable post goo.gl/r6Kq8s SVG2VectorDrawable plugins.jetbrains.com/plugin/8103?pr=idea Svg2Android inloop.github.io/svg2android Wonder Places github.com/rsicarelli/supportlibraryexample