View 정렬 방법(Vertical, Horizontal, Bottom, Top 등)

6. gravity : 자식뷰의 중력을 결정(Layout 에서 설정).. 중력이란 화면의 어느쪽에 정렬할 것인가? start, end, top, bottom, center, centerHorizontal, CenterVertical , |(파이프란인) 으로 여러 속성을 동시 설정가능

layout_gravity : 자식 뷰 각각의 중력을 결정... 자식 뷰(View에서 설정)에서 정의한다.

7. VIEW

View 객체들 배치 방법

8. 특정 View 간의 위치 배치
- 특정 뷰를 같이 배치하고자 할때, res/layout/activity_main.xml(해당 레이아웃 XML파일)의 뷰(EditView, Button, ImageView 등)에 아래와 같이 속성을 정의 한다.

layout_above="@id/[아이디]"
layout_toRightOf="@id/[아이디]"
layout_toEndOf="@id/[아이디]"
layout_toLeftOf="@id/[아이디]"
layout_toStartOf="@id/[아이디]"
layout_below="@id/[아이디]"

9. ConstraintLayout : 마지막에 나온 Layout으로, 제한(규칙)을 붙일 수 있는 레이아웃이다. 아래에 보면, 뷰들간에 속성을 정의할 수 있도록 되어 있다. 또한 이미지뷰를 상단에 꽉 채우려면, 여백을 0으로 설정하고, layout_widthmatch_constraints 속성을 준다. match_constraints 속성은 LinearLayout의 가중치(weight) 속성과 비슷. layout_width0dp로 주고, 좌우를 꽉 채울 때 사용.

--app:layout_constraintStart_toStartOf="[parent|다른뷰의 id]" : 현재 뷰의 왼쪽과 부모나 다른뷰의 왼쪽을 붙임
--app:layout_constraintEnd_toEndOf="[parent|다른뷰의 id]" : 현재 뷰의 오른쪽과 부모나 다른뷰의 오른쪽을 붙임
--app:layout_constraintTop_toTopOf="[parent|다른뷰의 id]" : 현재 뷰의 위쪽과 부모나 다른뷰의 위쪽을 붙임


...................

 

 

Posted by 목표를 가지고 달린다
,