The Android Support Library v26 brings lots of new features to our Android apps, including fonts as resources, downloadable fonts, emoji support, an autosizing TextView, physics driven animations via Spring and Fling, backwards compatibility for animated vectors, and a slimmer library by increasing the minSdkVersion to 14. If it isn’t already, the minSdkVersion for all of your apps should now be set to 14.

If you aren’t familiar with the Android Support Library, you’re required to compile against the same Android API level as the support library version. In other words, make sure that you have your <TargetFramework> set to 8.0 (API 26) to compile against the Android Support Library v26. To get support for Android 8.0, you can follow installation instructions here:

Font support in XML

You can now put fonts in a new font resource folder. Use Resources.GetFont or ResourcesCompat.GetFont to load font resources in your application.

e.g. Defining a font in XML in the Resources/font folder:

Using a font resource in a View:

NuGet:

https://www.nuget.org/packages/Xamarin.Android.Support.v4/26.0.2-beta1

Requires:

API 14+

Downloadable Fonts

There is a new FontsContractCompat class that allows you to request fonts from a font provider instead of bundling them inside your application. You can use the font provider through Google Fonts (800+ fonts).

To use this, first create a FontRequest:

Second, you need to register a FontRequestCallback which implements OnTypefaceRetrieved(Android.Graphics.Typeface typeface) and OnTypefaceRequestFailed(int reason). We’ve created one that you can explore in this example:

Finally, you need to request the font:

FontsContractCompat.RequestFont(this, request, callback, GetHandlerThreadHandler());

You can also directly request a font in XML:

NuGet:

https://www.nuget.org/packages/Xamarin.Android.Support.v4/26.0.2-beta1

Sample Project:

https://github.com/xamarin/monodroid-samples/tree/android-o/android-o/DownloadableFonts

Requires:

API 14+

Google Play Services 11+

Emoji Compatibility

The EmojiCompat support library allows your devices to be up to date with the latest emoji without requiring an Android OS update. This prevents those pesky tofu characters(□) from showing up!

EmojiCompat has two main libraries: downloadable or bundled.

Downloadable

As outlined earlier in the Downloable Fonts section of this blog post, you first need to make a FontRequest to create an FontRequestEmojiCompatConfig.

NuGet:

https://www.nuget.org/packages/Xamarin.Android.Support.Emoji/26.0.2-beta1

Bundled

Bundled makes life a little easier at the cost of about 7mb of a bundled font. All that’s required is that you create a BundledEmojiCompatConfig:

NuGet:

https://www.nuget.org/packages/Xamarin.Android.Support.Emoji.Bundled/26.0.2-beta1

Emoji Widgets

The EmojiCompat library provides us with three main widgets to display emojis with:

EmojiTextView, EmojiEditTExt, and EmojiButton

Sample Project:

https://github.com/xamarin/monodroid-samples/tree/android-o/android-o/EmojiCompat

Requires:

API 19+

TextView Autosizing

Your TextView will now increase text size when the container gets larger. There are three ways you can set up autosizing of TextView, explained below.

Default

Start by declaring the android:autoSizeTextType to uniform.

Granularity

You can also define a range of minimum and maximum text sizes for your TextView. It will also increase in increments defined by your step granularity.

Preset Sizes

Finally you can specify all of the values that TextView can size to when auto-sizing. You can specify an array resource of pre-set sizes:

Now you just need to specify the android:autoSizePresetSizes value for the array we already created:

NuGet:

https://www.nuget.org/packages/Xamarin.Android.Support.v4/26.0.2-beta1

Requires:

API 14+

Dynamic Animation

You can now use velocity-based animations instead of duration based ones. These animations are natural looking, with physics that mimic a fling gesture or a spring.

To create our first dynamic animation, create a new SpringAnimation object with a View, ViewProperty, and finalPosition.

There are two main concepts that you can set the spring to: Stiffness and DampingRatio.
Stiffness determines how fast the spring will snap back, while DampingRatio determines how bouncy the spring is.

You can then set your StartVelocity and Start the animation!

NuGet:

https://www.nuget.org/packages/Xamarin.Android.Support.Dynamic.Animation/26.0.2-beta1

Sample Project:

https://github.com/JonDouglas/AndroidSupportv26Samples/tree/master/SpringAnimationSample

Requires:

API 14+

AnimatedVectorDrawableCompat (Bonus)

If you’re unaware of AnimatedVectorDrawableCompat, it’s a pretty nifty library for morphing between paths and interpolating along a path to create stunning animations, logo transitions, and more. These have all now been backported to API 14, which allows for these beautiful animated vectors to run on older devices.

You can create your own beautiful animated vector drawables through XML by creating an <animated-vector> element and attaching <pathInterpolators> to the <objectAnimator> defined. If you aren’t the best animator, you can start here with a tool by Alex Lockwood:

NuGet:

https://www.nuget.org/packages/Xamarin.Android.Support.Animated.Vector.Drawable/26.0.2-beta1

Sample Project:

https://github.com/JonDouglas/AndroidSupportv26Samples/tree/master/EndlessPinJump

https://github.com/JonDouglas/AndroidSupportv26Samples/tree/master/AndroidToAppleVectorLogo

Requires:

API 14+

Summary

There are many rich features that Android ships within their support libraries that you can leverage in your applications. These features are typically backwards compatible to the minSdkVersion the support library defines. Now’s your chance to explore what the support libraries can provide for your applications!

Discuss this post on the Xamarin Forums