AOS

ConstraintLayout

asu2880 2022. 4. 4. 16:23

1. app:layout_constraintRight_toRightOf=”parent”

  • 의미
    : button1 right의 constraint를 줄건데, 이건 parent의 right다. 라는 의미
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintRight_toRightOf="parent" />


2. ConstraintLayout Chain

  • 의미
    : button1과 button2를 서로 연결(서로가 연결)
    <Button
        android:id="@+id/button1"
        android:text="button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toLeftOf="@id/button2" />

    <Button
        android:id="@+id/button2"
        android:text="button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintLeft_toRightOf="@+id/button1" />


3. chainStyle

  • Spread Chain
    : 기본 모드는 spread모드이며 사용 가능한 공간 내에서 동일한 간격으로 체인의 보기를 배치

  • Spread Inside Chain
    : spread_inside체인의 가장 바깥쪽 뷰를 바깥쪽 가장자리에 스냅한 다음 사용 가능한 공간 내에서 동일한 간격으로 체인의 나머지 뷰를 배치하는 것

  • Packed Chain
    : packed보기를 함께 묶고(약간 구분하기 위해 여백을 제공할 수 있지만) 사용 가능한 공간 내에서 그룹을 중앙에 배치하는 것

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:layout_width="match_parent"
  android:layout_height="match_parent">

  <Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="button1"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintLeft_toRightOf="@+id/button2" />

  <Button
    android:id="@+id/button2"
    android:text="button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_constraintHorizontal_chainStyle="packed"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toLeftOf="@id/button1" />

</android.support.constraint.ConstraintLayout>


4. app:layout_constraintHorizontal_bias="0"

  • 의미
    - 왼쪽으로 붙여서 쓸수있는 속성
    - default값은 0.5
    - 0이면 왼쪽으로, 1이면 오른쪽으로 배치

 

참고 사이트

https://medium.com/@futureofdev/android-constraintlayout-%EC%89%BD%EA%B2%8C-%EC%95%8C%EC%95%84%EA%B0%80%EC%9E%90-62d2ded79c17

 

Android ConstraintLayout 쉽게 알아가자

LinearLayout이나 RelativeLayout을 쓰다보면 ConstraintLayout을 왜쓰면 좋을지 궁금증을 가지게 됩니다. 저도 그랬고, 새로 학습해야해서 잠깐 미뤄뒀는데, 직접 써보니 이게 왠걸, 정말 재미있는 레이아웃

medium.com

https://constraintlayout.com/

 

ConstraintLayout

Welcome to ConstraintLayout.com ConstraintLayout.com is a community-sourced documentation hub all about ConstraintLayout. While there is lots of documentation and plenty of blog posts about ConstraintLayout, it is such an immense and powerful beast, that a

constraintlayout.com

https://academy.realm.io/kr/posts/cool-constraintlayout-droidcon-boston-2017/

 

ConstraintLayout과 함께 안드로이드 앱 편하게 개발하기

저는 Atlassian에서 안드로이드 트렐로 앱을 개발하고 있는 Huyen Tue Dao입니다. 이번 강연에서는 안드로이드의 새로운 레이아웃인 Constraint Layout에 대해 살펴보겠습니다. ConstraintLayout Constraint Layout은

academy.realm.io

https://seminzzang.tistory.com/21

 

[안드로이드 스튜디오 정리#1-6] ConstraintLayout

이 게시물은 다음 링크를 참조하여 학습했습니다. 안드로이드 컨스트레인트레이아웃. (Android ConstraintLayout) 1. 안드로이드 레이아웃 작성. 안드로이드 앱을 개발할 때, UI 화면을 구성하는 작업은

seminzzang.tistory.com

 

728x90
반응형

'AOS' 카테고리의 다른 글

Google Fitness Api  (1) 2022.04.13
Android - Bottom Sheet Dialog  (0) 2021.08.23
안드로이드 웹뷰 통신  (0) 2021.06.28
meta-tag보안  (0) 2021.06.01
보안(서버도메인 등)  (0) 2021.06.01