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://academy.realm.io/kr/posts/cool-constraintlayout-droidcon-boston-2017/
https://seminzzang.tistory.com/21
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 |