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

안드로이드 스튜디오 겹침문제...

0 추천
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:id="@+id/noticeText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:background="@color/colorPrimary"
        android:drawableLeft="@drawable/ic_textsms_black_24dp"
        android:drawableStart="@drawable/ic_textsms_black_24dp"
        android:padding="10dp"
        android:text="공지사항"
        android:textColor="#ffffff"
        android:textStyle="bold" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/colorPrimaryDark">
    
    <TextView
        android:id="@+id/nameText"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:text="토크쇼"
        android:layout_gravity = "center"
        android:padding="3dp"
        android:layout_marginLeft="8dp"
        android:textColor="#ffffff"
        android:textColorHint="#ffffff"/>

    <TextView
        android:id="@+id/dateText"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:text="2018-05-03"
        android:layout_gravity="center"
        android:padding="3dp"
        android:textColor="#ffffff"
        android:textColorHint="#ffffff"/>
    </LinearLayout>


</android.support.constraint.ConstraintLayout>

이렇게 코딩을 했는데 TextView끼리 다 겹쳐요 뭐가 잘못된거죠..?ㅠㅠ

Hyunyy (400 포인트) 님이 2018년 5월 3일 질문

1개의 답변

+2 추천
 
채택된 답변
ConstraintLayout는 레이아웃 구성하는 방식이 RelativeLayout하고 비슷하다고 생각하시면 됩니다.

각 view간의 연결로 레이아웃을 구성하는 것이기때문에

app:layout_constraintBottom_toBottomOf="viewID"
app:layout_constraintEnd_toStartOf="viewID"
app:layout_constraintStart_toStartOf="viewID"
app:layout_constraintTop_toTopOf="viewID"

viewID를 이용해서 위치를 잡아주셔야  됩니다.

그외에 사이즈라던가 마진 등 세세한 옵션은 document를 보시면 됩니다.
익명사용자 님이 2018년 5월 3일 답변
Hyunyy님이 2018년 5월 4일 채택됨
그렇다면 저기서 LinearLayout으로 바굴려면 어떻게 해야하나요..? 제가 3.0 쓰다가 3.1 패치되서 처음쓰는건데 예전에는 <LinearLayout xmlns:android="http://xxxxxxxxxxxxxx"> 이렇게 나왔던걸로 기억하거든요 맨 윗줄이..
android.support.constraint.ConstraintLayout 을 통째로 선택하시고 linearlayout입력하면 자동으로 추천입력이 뜰거에요
오오오 정말로 감사합니다 !!!
...