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

Building a modern Android UI

Building a modern Android UI

Presented at http://chicagoroboto.com with John Hoford, this talk gives an overview of the current expectations of creating an android application, the different tools and framework available, as well as exploring how ConstraintLayout could be taken advantage of in this light.

Nicolas Roard

April 21, 2017
Tweet

More Decks by Nicolas Roard

Other Decks in Programming

Transcript

  1. Vertical LinearLayout RelativeLayout Image Image Vertical LinearLayout TextView Horizontal LinearLayout

    EditText TextView Horizontal LinearLayout EditText TextView TextView
  2. Vertical LinearLayout RelativeLayout Image Image Vertical LinearLayout TextView Horizontal LinearLayout

    EditText TextView Horizontal LinearLayout EditText TextView TextView Horizontal LinearLayout Button Button
  3. Vertical LinearLayout RelativeLayout Image Image Vertical LinearLayout TextView Horizontal LinearLayout

    EditText TextView Horizontal LinearLayout EditText TextView TextView Horizontal LinearLayout Button Button
  4. Vertical LinearLayout RelativeLayout Image Image Vertical LinearLayout TextView Horizontal LinearLayout

    EditText TextView Horizontal LinearLayout EditText TextView TextView Horizontal LinearLayout Button Button
  5. Vertical LinearLayout RelativeLayout Image Image Vertical LinearLayout TextView Horizontal LinearLayout

    EditText TextView Horizontal LinearLayout EditText TextView TextView Horizontal LinearLayout Button Button
  6. What • Small (130 Kb) • Unbundled Library • Flexible

    foundation • Direct Resolution • Linear System Solver
  7. What • Small (130 Kb) • Unbundled Library • Flexible

    foundation • Direct Resolution • Linear System Solver Linear System Solver
  8. What • Small (130 Kb) • Unbundled Library • Flexible

    foundation • Direct Resolution • Linear System Solver Linear System Solver Constraints System
  9. What • Small (130 Kb) • Unbundled Library • Flexible

    foundation • Direct Resolution • Linear System Solver Linear System Solver Direct Resolution Constraints System
  10. What • Small (130 Kb) • Unbundled Library • Flexible

    foundation • Direct Resolution • Linear System Solver Linear System Solver Direct Resolution Constraints System UI Builder
  11. What • Small (130 Kb) • Unbundled Library • Flexible

    foundation • Direct Resolution • Linear System Solver Linear System Solver Direct Resolution Constraints System UI Builder Inference
  12. 1.0.2 • 16 updates since Google IO’16 • Faster! •

    New Features • Improved Visual Editor support • Default Layout in Android Studio
  13. Row

  14. Row

  15. How it works • Horizontal Chain, packed • Bias to

    0 • Resizable element set to default=wrap
  16. Tools attributes • tools: • tools:showIn • tools:layout • tools:listitem

    • tools:parentTag https://developer.android.com/studio/write/tool-attributes.html
  17. Tools attributes • tools: • tools:showIn • tools:layout • tools:listitem

    • tools:parentTag override attributes at design time https://developer.android.com/studio/write/tool-attributes.html
  18. Tools attributes • tools: • tools:showIn • tools:layout • tools:listitem

    • tools:parentTag override attributes at design time shows this layout embedded in another one https://developer.android.com/studio/write/tool-attributes.html
  19. Tools attributes • tools: • tools:showIn • tools:layout • tools:listitem

    • tools:parentTag override attributes at design time shows this layout embedded in another one which layout to use for a fragment https://developer.android.com/studio/write/tool-attributes.html
  20. Tools attributes • tools: • tools:showIn • tools:layout • tools:listitem

    • tools:parentTag override attributes at design time shows this layout embedded in another one which layout to use for a fragment which layout for a list item https://developer.android.com/studio/write/tool-attributes.html
  21. Tools attributes • tools: • tools:showIn • tools:layout • tools:listitem

    • tools:parentTag override attributes at design time shows this layout embedded in another one which layout to use for a fragment which layout for a list item define which layout to use as parent for merge tag https://developer.android.com/studio/write/tool-attributes.html
  22. Useful shortcuts • <esc> to select a parent group •

    <ctrl><shift> to switch between XML and Design mode • double-click on included elements <left> <right>
  23. Inference Automatically create constraints • Based on probability a model

    for connections • Constrains unconstrained views • Does not move views (not an alignment tool)
  24. Inference Automatically create constraints • Based on probability a model

    for connections • Constrains unconstrained views • Does not move views (not an alignment tool)
  25. Inference Automatically create constraints • Based on probability a model

    for connections • Constrains unconstrained views • Does not move views (not an alignment tool)
  26. Inference Automatically create constraints • Based on probability a model

    for connections • Constrains unconstrained views • Does not move views (not an alignment tool)
  27. Inference Automatically create constraints • Based on probability a model

    for connections • Constrains unconstrained views • Does not move views (not an alignment tool)
  28. Inference Automatically create constraints • Based on probability a model

    for connections • Constrains unconstrained views • Does not move views (not an alignment tool)
  29. Animating Content • View state change: StateListAnimator • android:stateListAnimator •

    Vector Drawable • <vector> + <animated-vector> + <objectAnimator> • Reveal animation • Ripples
  30. Activity Transitions • enter & exit transitions • explode, slide,

    fade • shared elements • bounds, clip, transform, image transform
  31. Activity Transitions • enter & exit transitions • explode, slide,

    fade • shared elements • bounds, clip, transform, image transform
  32. ConstraintSet • Separate views from how we layout them •

    Encapsulate all constraints in an object
  33. ConstraintSet • Separate views from how we layout them •

    Encapsulate all constraints in an object • You can apply a ConstraintSet to an existing ConstraintLayout
  34. ConstraintSet • Separate views from how we layout them •

    Encapsulate all constraints in an object • You can apply a ConstraintSet to an existing ConstraintLayout • Switch between multiple ConstraintSet
  35. ConstraintSet ConstraintSet mConstraintSet1 = new ConstraintSet(); // create a Constraint

    Set ConstraintSet mConstraintSet2 = new ConstraintSet(); // create a Constraint Set
  36. ConstraintSet ConstraintSet mConstraintSet1 = new ConstraintSet(); // create a Constraint

    Set ConstraintSet mConstraintSet2 = new ConstraintSet(); // create a Constraint Set mConstraintSet2.clone(context, R.layout.state2); // get constraints from layout setContentView(R.layout.state1); mConstraintLayout = (ConstraintLayout) findViewById(R.id.activity_main); mConstraintSet1.clone(mConstraintLayout); // get constraints from ConstraintSet
  37. ConstraintSet ConstraintSet mConstraintSet1 = new ConstraintSet(); // create a Constraint

    Set ConstraintSet mConstraintSet2 = new ConstraintSet(); // create a Constraint Set mConstraintSet2.clone(context, R.layout.state2); // get constraints from layout setContentView(R.layout.state1); mConstraintLayout = (ConstraintLayout) findViewById(R.id.activity_main); mConstraintSet1.clone(mConstraintLayout); // get constraints from ConstraintSet mConstraintSet1.applyTo(mConstraintLayout);
  38. ConstraintSet ConstraintSet mConstraintSet1 = new ConstraintSet(); // create a Constraint

    Set ConstraintSet mConstraintSet2 = new ConstraintSet(); // create a Constraint Set mConstraintSet2.clone(context, R.layout.state2); // get constraints from layout setContentView(R.layout.state1); mConstraintLayout = (ConstraintLayout) findViewById(R.id.activity_main); mConstraintSet1.clone(mConstraintLayout); // get constraints from ConstraintSet mConstraintSet1.applyTo(mConstraintLayout);
  39. ConstraintSet ConstraintSet mConstraintSet1 = new ConstraintSet(); // create a Constraint

    Set ConstraintSet mConstraintSet2 = new ConstraintSet(); // create a Constraint Set mConstraintSet2.clone(context, R.layout.state2); // get constraints from layout setContentView(R.layout.state1); mConstraintLayout = (ConstraintLayout) findViewById(R.id.activity_main); mConstraintSet1.clone(mConstraintLayout); // get constraints from ConstraintSet TransitionManager.beginDelayedTransition(mConstraintLayout); mConstraintSet1.applyTo(mConstraintLayout);
  40. • Programmatically change individual parameters • Use TransitionManager to smooth

    animation Individual View Animation //Find the view you are over and set minimum height TransitionManager.beginDelayedTransition(myConstraintLayout); View child = myConstraintLayout.getChildAt(current); child.setMinimumHeight(400);
  41. ConstraintLayout & Motion • Flat Hierarchy == No clipping issues

    • Scene Graph • ConstraintSet == Keyframe
  42. ConstraintLayout : UI director • What you can do with

    widgets, you can do with components • Everything is still the same • A lot more flexible • Easy to build and test
  43. Custom Transitions • ConstraintSet • Custom TransitionSet • Support library

    physics TransitionManager.beginDelayedTransition(cl, new MyCustomAnimationSet())
  44. Custom Transitions • ConstraintSet • Custom TransitionSet • Support library

    physics TransitionManager.beginDelayedTransition(cl, new MyCustomAnimationSet())
  45. What’s next • Android Studio 2.4 • default RTL support

    in ConstraintLayout editor • Component Tree • Slice • ConstraintLayout 1.1 • Barriers • Percent dimension • Groups
  46. Groups • Apply operations on a group of widget •

    opacity • translate • elevation • visibility
  47. Fin

  48. Contact Nicolas Roard @camaelon +NicolasRoard John Hoford @johnhoford +johnhoford ConstraintLayout

    Documentation https://developer.android.com/ reference/android/support/constraint/ package-summary.html File Bugs & Feature Requests! http://b.android.com