티스토리 뷰
RelativeLayout
siblings 기준 position
- layout_above, layout_below, layout_toLeftOf, layout_toRightOf
parent 기준 position
- layout_centerHorizontal, layout_centerVertical
siblings 기준 정렬
- layout_alignTop, layout_alignBottom, layout_alignLeft, layout_alignRight, layout_alignBaseline
parent 기준 정렬
- layout_alignParentTop, layout_alignParentBottom, layout_alignParentLeft, layout_alignParentRight
ConstraintLayout 변경
RelativeLayout |
ConstraintLayout |
android:layout_alignParentLeft="true" |
app:layout_constraintLeft_toLeftOf="parent" |
android:layout_alignParentStart="true" |
app:layout_constraintStart_toStartOf="parent" |
android:layout_alignParentTop="true" |
app:layout_constraintTop_toTopOf="parent" |
android:layout_alignParentRight="true" |
app:layout_constraintRight_toRightOf="parent" |
android:layout_alignParentEnd="true" |
app:layout_constraintEnd_toEndOf="parent" |
android:layout_alignParentBottom="true" |
app:layout_constraintBottom_toBottomOf="parent" |
android:layout_centerHorizontal="true" |
app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" |
android:layout_centerVertical="true" |
app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" |
android:layout_centerInParent="true" |
app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintBottom_toBottomOf="parent" |
간단한 로그인 화면 예제
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView android:id="@+id/label" android:layout_width="match_parent"
android:layout_height="wrap_content" android:text="Email" />
<EditText android:id="@+id/inputEmail" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_below="@id/label" />
<Button android:id="@+id/btnLogin" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_below="@id/inputEmail"
android:layout_alignParentLeft="true" android:layout_marginRight="5dp"
android:text="Login" />
</RelativeLayout>
실행화면
PercentRelativeLayout
예제
<android.support.percent.PercentRelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="@+id/top_left"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_alignParentTop="true"
android:background="#ff44aacc"
app:layout_heightPercent="20%"
app:layout_widthPercent="70%" />
<View
android:id="@+id/top_right"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/top_left"
android:background="#ffe40000"
app:layout_heightPercent="20%"
app:layout_widthPercent="30%" />
<View
android:id="@+id/bottom"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="@+id/top_left"
android:background="#ff00ff22"
app:layout_heightPercent="80%" />
</android.support.percent.PercentRelativeLayout>
실행화면
'android' 카테고리의 다른 글
| [안드로이드] RecyclerView ( ListView와 차이 ) (0) | 2018.07.04 |
|---|---|
| [안드로이드] ListView, ArrayAdapter 사용하기 (1) | 2018.07.04 |
| [안드로이드] TextInputLayout, EditText (hint/placeholder, error message, 문자열 counting, password visibility) (0) | 2018.06.29 |
| [안드로이드] view layouts (3) FrameLayout (0) | 2018.06.28 |
| [안드로이드] view layouts (1) LinearLayout (0) | 2018.06.28 |
- Total
- Today
- Yesterday
- HTTP
- handshake
- LinearLayout
- C++
- ConstraintLayout
- 윈도우
- DATABASE
- 이진탐색트리
- C
- 네트워크
- frameLayout
- adapter
- 백준
- 스프링
- 퀵정렬
- 정렬 알고리즘
- debug
- windows
- 백준알고리즘
- RelativeLayout
- 알고리즘
- WinDbg
- Android
- BOJ
- 안드로이드
- layout
- 스프링부트
- OS
- listview
- 운영체제
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |