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

Google I/O '18 Extended In Daejeon Part2

Google I/O '18 Extended In Daejeon Part2

pluulove (노현석)

August 04, 2018
Tweet

More Decks by pluulove (노현석)

Other Decks in Programming

Transcript

  1. ConstraintLayout Easily create User Interface Flexible layout Flat hierarchies UI

    Builder Back compatible starting from API 9 (99.99% of devices) Support library : ~160Kb
  2. ConstraintLayout 1.0 2017 Relative positioning Center & Bias positioning Group

    behavior (chains / weights) Visibility behavior (gone handling & margins) Aspect ratio ConstraintSet Guidelines
  3. ConstraintHelper ӝઓ View੄ ଵઑ݅ ࣗਬ Flat hierarchy Viewח ࠂࣻ Helperী

    ଵઑ оמ ӝࠄ੸ਵ۽ Viewী Tagܳ ૑੿೧ ౠ੿ ز੘ਸ ࢸ੿
  4. <android.suppo_.constraint.Linear android:id="@+id/linear" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" app:constraint_referenced_ids="bumon1,bumon2,bumon3" app:layout_constraintBomom_toBomomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintSta__toSta_Of="parent" app:layout_constraintTop_toTopOf="parent"

    /> <android.suppo_.constraint.Linear android:id="@+id/linear" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" app:constraint_referenced_ids="bumon1,bumon2,bumon3" app:layout_constraintBomom_toBomomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintSta__toSta_Of="parent" app:layout_constraintTop_toTopOf="parent" />
  5. Flow Implements FlexboxLayout-like semantics Overflow elements will be pushed to

    the next row Still flat layout! Able to position outside elements relative to the ones in Flow
  6. Layers Hide / Show / Lock elements in the editor

    Manipulate graphically a collection of views Supports transforms, etc. Can be set as the bounding box of the referenced views
  7. Circular Reveal Use existing circular reveal code …but handles the

    math for you only applies to referenced views
  8. Before private val constraintSet1 by lazy { ConstraintSet() } private

    val constraintSet2 by lazy { ConstraintSet() } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) // get constraints from layout constraintSet2.clone(this, R.layout.layout_small) setContentView(R.layout.layout_large) // get constraints from ConstraintSet constraintSet1.clone(mConstraintLayout) }
  9. After override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.layout) root.setLayoutDescription(R.xml.state) }

    fun toogle(v: View) { TransitionManager.beginDelayedTransition(root) root.setState(if (closed) R.id.large else R.id.small, 1080, 1920) closed = !closed }
  10. More After override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.layout) root.setLayoutDescription(R.xml.state)

    } fun toogle(v: View) { TransitionManager.beginDelayedTransition(root) root.setState(if (closed) R.id.large else R.id.small, 1080, 1920) closed = !closed } Defined in XML
  11. State XML : Size Qualifiers <ConstraintLayoutState xmlns:app="hmp://schemas.android.com/apk/res-auto"> <State app:constraints="@layout/layout_small"> <Constraints

    app:constraints="@layout/layout_small" app:region_widthLessTahn="550dp" /> <Constraints app:constraints="@layout/layout_large" app:region_widthMoreTahn="450dp" /> </State> </ConstraintLayoutState>
  12. Layout Management Centralize multiple layouts in a single XML Allows

    to easily initialize and deal with different representations for your layout Size qualifiers & live resize
  13. motion.xml <android.suppo_.constraint.motion.MotionLayout app:layoutDescription="@xml/scene_20"> <ImageView /> <TextView /> <ImageBumon /> <TextView

    /> <ImageView /> <com.google.androidstudio.motionlayoutexample.helpers.
 ExampleFlyinBounceHelper app:constraint_referenced_ids=“imageView9" /> </android.suppo_.constraint.motion.MotionLayout> https://github.com/googlesamples/android-ConstraintLayoutExamples/blob/master/motionlayout/src/main/res/layout/motion_20_reveal.xml
  14. scene_20.xml https://github.com/googlesamples/android-ConstraintLayoutExamples/blob/master/motionlayout/src/main/res/xml/scene_20.xml <MotionScene> <ConstraintSet android:id="@+id/sta_"> <Constraint android:id="@id/imageView8" android:layout_width="0dp" android:layout_height="match_parent" android:layout_marginEnd="0dp"

    motion:layout_constraintEnd_toEndOf="parent" motion:layout_constraintSta__toSta_Of="parent" motion:layout_constraintTop_toTopOf="parent" motion:layout_editor_absoluteX="0dp" motion:layout_editor_absoluteY=“0dp" /> … </ConstraintSet> <ConstraintSet android:id=“@+id/end"> <Constraint android:id="@id/imageView8" android:layout_width="0dp" android:layout_height="326dp" android:layout_marginTop="0dp" android:layout_marginBomom="-1dp" motion:layout_constraintEnd_toEndOf="parent" motion:layout_constraintTop_toTopOf="parent" /> … </ConstraintSet>
  15. https://github.com/googlesamples/android-ConstraintLayoutExamples/blob/master/motionlayout/src/main/res/xml/scene_20.xml motion:layout_constraintEnd_toEndOf="parent" motion:layout_constraintSta__toSta_Of="parent" motion:layout_constraintTop_toTopOf="parent" motion:layout_editor_absoluteX="0dp" motion:layout_editor_absoluteY=“0dp" /> … </ConstraintSet> android:layout_marginBomom="-1dp"

    motion:layout_constraintEnd_toEndOf="parent" motion:layout_constraintTop_toTopOf="parent" /> … </ConstraintSet> <Transition motion:constraintSetEnd="@+id/end" motion:constraintSetSta_="@+id/sta_" motion:duration="1000" motion:interpolator="linear"> <OnSwipe motion:touchAnchorId="@+id/imageView8" motion:touchAnchorSide="bomom" motion:dragDirection="dragUp" />
  16. https://github.com/googlesamples/android-ConstraintLayoutExamples/blob/master/motionlayout/src/main/res/xml/scene_20.xml <OnSwipe motion:touchAnchorId="@+id/imageView8" motion:touchAnchorSide="bomom" motion:dragDirection="dragUp" /> <KeyFrameSet> <KeyAmribute android:rotation="0" motion:framePosition="1"

    motion:target="@id/imageView9" /> <KeyPosition motion:framePosition="27" motion:percentX="-0.2585034" motion:percentY="0.50630915" motion:target="@id/imageView9" motion:type="deltaRelative" /> </KeyFrameSet> </Transition> </MotionScene>