본문 바로가기
📱 Android

[ConstraintLayout] ConstraintLayout에 대해 알아보자

by 콩드로이드 2019. 8. 11.

ConstraintLayout은 위젯의 위치와 크기를 유연한 방식으로 조절하게끔 허용된 ViewGroup입니다

 

상대적 배치

 

기존에 없었던 attribute를 통해 위젯간의 상대적 배치가 편리해짐

 

예를 들어 View를 2개를 선언한다면

 

 

4개의 점을 이용해 원하는 View랑 배치를 조정하고, margin값을 적용하면 GUI에서도 보기 편하게 표시가 됩니다

GUI에 보기 편하게 표시되는 것이 가장 큰 편리함이라 생각했습니다

 

 

그 외에도 Constraint Layout을 사용하면 위 사진 처럼 제공되는 기능이 많으니 직접 해보는 것을 추천합니다

 

처음 썼을 땐 당황스러웠지만 손에 익고 나면 Constraint Layout만큼 편한 Layout은 없는 것 같습니다 

 

 

참고 문서 : https://developer.android.com/reference/android/support/constraint/ConstraintLayout

 

ConstraintLayout  |  Android Developers

ConstraintLayout public class ConstraintLayout extends ViewGroup java.lang.Object    ↳ ViewGroup      ↳ android.support.constraint.ConstraintLayout Known direct subclasses MotionLayout A subclass of ConstraintLayout for building animations.  A ConstraintLa

developer.android.com