Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- break
- 노개북
- Kotlin
- til
- CREATE
- while
- JavaScript
- 개발자 번아웃
- continue
- Java
- Today I Learned
- VS Code
- react
- 개발자북클럽
- 이클립스 설치
- 자바스크립트
- return
- MySQL
- 버전 표시 방법
- CSS
- 제어문
- HTML
- JavaScript 이벤트
- 인스턴스
- If
- vscode
- 노마드코더
- IT잡학사전
- 리액트
- 메서드
Archives
- Today
- Total
윤제니
Linear Layout 본문
Linear Layout
=> View를 수평 또는 수직 방향으로 배치할 수 있는 레이아웃
orientation 속성 | 배치방향 |
android:orientation="vertical" | 하위 뷰들을 수직방향으로 배치 |
android:orientation="horizontal" | 하위 뷰들을 수평방향으로 배치 |
- gravity속성과 layout_gravity속성의 차이
gravity 속성 | 모든 하위 뷰에 대한 중력 방향(배치방향) 결정 |
android:gravity="top,center,bottm 중 1택" | |
layout_gravity 속성 | 해당 Group View에 속하는 하위 View들이 가지는 속성 => ViewGroup의 gravity 속성에 의해서 결정된 원래 자기 자신의 위치에서 중력 방향 결정 |
android:layout_gravity="top,center,bottm 중 1택" |
<LinearLayout
android:layout_width="500dp"
android:Llayout_height="200dp"
android:background="@color/colorRed"
android:gravity="bottom"
android:orientation="horizontal" >
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="button1" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="button2" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="button3" />
</LinearLayout>
위와 다르게 아래는 layout_gravity 속성을 지정하여 상위 ViewGroup에 자신만의 원하는 기능을 요청할 수 있다.
<LinearLayout
android:layout_width="500dp"
android:Llayout_height="200dp"
android:background="@color/colorRed"
android:gravity="bottom"
android:orientation="horizontal" >
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_weight="1"
android:text="button1" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center"
android:text="button2" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="button3" />
</LinearLayout>
'Android' 카테고리의 다른 글
Android - Java 프로젝트에서 Kotlin 사용하기 (0) | 2021.09.08 |
---|