개발 일기

ConstraintLayout - Guideline 본문

Client/안드로이드

ConstraintLayout - Guideline

이건욱

Gulideline

화면을 그릴 때 가이드 라인을 그릴수가 있습니다.

따라서 비율 및 시작점 혹은 끝점을 기준으로 위치를 설정할수가 있습니다.

 

방향 설정

android:orientation="horizontal|vertical"

 

위치 설정

퍼센트로 설정

 app:layout_constraintGuide_percent="0.3"

시작 위치 끝나는 위치 설정

app:layout_constraintGuide_begin="24dp"
app:layout_constraintGuide_end="16dp"

 

예제

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
                                                   xmlns:app="http://schemas.android.com/apk/res-auto"

                                                   android:id="@+id/container"
                                                   android:layout_width="match_parent"
                                                   android:layout_height="match_parent">


    <View android:layout_width="0dp"
          android:layout_height="0dp"
          app:layout_constraintStart_toEndOf="@+id/guideline"
          app:layout_constraintTop_toTopOf="parent"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          android:background="@color/colorPrimary"
    />
    <androidx.constraintlayout.widget.Guideline
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:id="@+id/guideline"
            app:layout_constraintGuide_begin="80dp"
            android:orientation="vertical" />
</androidx.constraintlayout.widget.ConstraintLayout>

 

'Client > 안드로이드' 카테고리의 다른 글

ConstraintLayout - Flow  (0) 2020.05.22
ConstraintLayout - Group  (0) 2020.05.21
ConstraintLayout - Barrier  (0) 2020.05.21
ConstraintLayout - Chains  (0) 2020.05.20
Intent Flag ?  (0) 2020.05.19
Comments