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

Uma nova forma de construir layouts

Uma nova forma de construir layouts

Slides da palestra apresentada na trilha Android do The Developer's Conference 2017 em Florianópolis.

Tweet

More Decks by David Tiago Conceição

Other Decks in Programming

Transcript

  1. A base: Constraints • Atributos XML ◦ Leitura ◦ Edição

    ... <android.support.constraint.ConstraintLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageView android:id="@+id/details_image" android:layout_width="0dp" android:layout_height="0dp" android:layout_marginLeft="0dp" android:layout_marginRight="0dp" android:layout_marginTop="0dp" android:scaleType="centerInside" app:layout_constraintDimensionRatio="h,1:1" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" ...
  2. Ainda sobre dimensões • match_parent ◦ Constraints + 0dp ◦

    match_constraint • Limitadas ◦ layout_constraintWidth_default • Baseadas em outra view
  3. Via Java • Constraint sets @BindView(R.id.details_root_constraint) ConstraintLayout rootConstraintLayout; // …

    ConstraintSet constraintSet = new ConstraintSet(); constraintSet.clone(rootConstraintLayout); // ... constraintSet.applyTo(rootConstraintLayout);
  4. Via Java • Constraint sets • ConstraintSet.connect(startID, startSide, endID, endSide,

    margin) • Animações TransitionManager.beginDelayedTransition( rootConstraintLayout); constraintSet.applyTo(rootConstraintLayout);
  5. E o futuro? • Android Studio • Performance • Padronização

    • Barriers ◦ Limites • Operações em grupo
  6. E o passado? • Fácil aprendizado • Estável • Mudanças

    API ◦ Beta • wrap_content ◦ Pequenas falhas
  7. O que queremos? • Performance ◦ Hierarquia plana ◦ Execução

    única • Simplicidade ◦ Drag and drop ◦ Constraints • Pixel perfect ◦ Flexibilidade ◦ Componentes auxiliares • Previews
  8. Para saber mais? • Build a Responsive UI with ConstraintLayout:

    https://developer.android.com/training/constraint-layout/index.html • ConstraintLayout: https://developer.android.com/reference/android/support/constraint/Constra intLayout.html • Using ConstraintLayout to design your views: https://codelabs.developers.google.com/codelabs/constraint-layout/index.ht ml?index=..%2F..%2Findex#0 • ConstraintLayout, Inside and Out: http://wiresareobsolete.com/2016/07/constraintlayout-part-1/