5. The beginning
The Android support library was first release at 2011, bringing
support to thousands of devices, old as new.
The Goal: new API for old Android version
Starting with the famous v4.
14. How it works?
Fragments
● Extra cautious when committing transaction in Activity’s lifecycle callbacks!
● Avoid committing in Asynchronous callbacks!
● Use commitAllowingStateLoss() only as a last resort!
Revision 24.0.0 - Added Fragment.commitNow() for synchronous commit.
Revision 25.1.1 - FragmentTransaction.setAllowOptimization(true)
Revision 25.4.0 - Transactions are not allowed during state change.
Revision 26.0.0 - setAllowOptimization(true):deprecated , isStateSaved():added.
15. Versioning…?
Remove a fragment from backstack and start a new Activity
Ref: https://issuetracker.google.com/issues/37129908
16. AppCompat
Support library gives us the option to use the same
theme for devices with support for Material Design
even below API 21.
This means that we can customize one theme to
match almost all API levels.
In addition, we get to use some nice components
that were added in API 21,
like the Floating Action Button, Toolbar,
DrawerLayout and more, out-of-the-box.
21. Whats new?
Downloadable fonts
● Shrink APK size
● Google fonts catalog - over 800 free fonts
● Android Studio integration
● Font caching across multiple apps
22. Whats new?
public class ResizableTextView extends TextView {
private void setText(String text) {
// measure width and height
// calculate text size to fit in view
}
}
34. Versioning…?
ext {
supportLibVersion = '26.0.2'
}
dependencies {
compile "com.android.support:appcompat-v7:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
compile "com.android.support:support-annotations:${supportLibVersion}"
compile "com.android.support:support-vector-drawable:${supportLibVersion}"
compile "com.android.support:animated-vector-drawable:${supportLibVersion}"
}
TIP! Make your life easier, use a variable for the version
36. When?
When?
1. Targeting latest version but supporting older
versions with the same API’s.
2. Some components are only exists in the
Support Libraries.
38. Android, support me!
To sum it all up
● Use the support libraries!
● Do it right!
● Don’t re-invent the wheel
● Understand what you are doing (or at least try to)
● Bugs - don’t afraid to open!