마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

ConstraintLayout 또 쓰라고 하셔서 쓰는데 맞는건가요..?

0 추천

<?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/constraintlayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <View
        android:id="@+id/view"
        android:layout_width="match_parent"
        android:layout_height="10dp"
        android:background="@drawable/linearlayout_horizontal_line"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="15dp"
        android:layout_marginLeft="15dp"
        android:text="군 도"
        android:textSize="25dp"
        app:layout_constraintRight_toLeftOf="@id/ic_15"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toBottomOf="@id/view" />

    <ImageView
        android:id="@+id/ic_15"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintLeft_toRightOf="@id/title"
        app:layout_constraintTop_toBottomOf="@id/view"
        android:layout_marginTop="15dp"
        android:src="@drawable/ic_15"/>

    <View
        android:layout_width="match_parent"
        android:layout_height="3dp"
        android:background="@drawable/linearlayout_horizontal_line"
        app:layout_constraintTop_toBottomOf="@id/title"/>

ConstraintLayout 사용하는걸 연습하라하셔서 지금 버튼 클릭시 화면띄우는게 하나있는데

그걸 ConstraintLayout으로 만들어볼까 해서 만들고 있거든요..

근데 사진만큼 만들었는데 코드는 저만큼 양이 나옵니다..

 

가성비가 안좋다고해야하나요.. constraintRight_toRightof 이런 속성들을 하나하나 넣어서 

부모 아래 배치, 어느 뷰 옆에 배치, 아래배치 등 이런걸 다 연결해서 하다보니까 

뷰하나에도 코드 3~4줄이 자꾸들어가던데 원래이런건가요..?

 

군도,15 부분 보시면 수평배치이기때문에 Linearlayout이 더 좋지 않을까 했는데

그냥 Contraintlayout으로 뷰끼리 연결을 했는데 넘 비효율적이죠?...

Linearlayout이랑 Relatilayout 보다 Contraintlayout 많이 연습하라고 하셔서 안쓰려고했는데 말이죠...

Linearlayout이랑 Relatilayout도 쓸때에는 써줘야할까요

codeslave (3,940 포인트) 님이 2020년 9월 13일 질문
codeslave님이 2020년 9월 13일 수정

1개의 답변

+1 추천
복잡한 뷰를 구성할 때 나 그런 복잡한 뷰가 변경될 때 효과를 보는 레이아웃이라고 합니다.

상황에 맞게 여러 레이아웃들을 잘 활용하시는게 가장 좋습니다.
쭈쭈총각 (17,750 포인트) 님이 2020년 9월 14일 답변
...