티스토리 뷰
LinearLayout 은 하단과 같이 view 를 수평 혹은 수직으로 배치한다.
How to
◼ LinearLayout in XML
LinearLayout.LayoutParams
View group 이 view 를 배치할 때 따르는 규칙이다.
◼ ViewGroup.LayoutParams
View 의 크기를 설정한다.
- layout_width : view 너비
- layout_height : view 높이
◼ ViewGroup.MarginLayoutParams
View 주변의 여백을 설정한다.
XML 속성 | 의미 | 상세 그림 |
layout_margin | 해당 view 의 상, 하, 좌, 우 여백 설정 | |
layout_marginLeft | 해당 view 의 좌측 여백 설정 | |
layout_marginTop | 해당 view 의 상단 여백 설정 | |
layout_marginRight | 해당 view 의 우측 여백 설정 | |
layout_marginBottom | 해당 view 의 하단 여백 설정 |
◼ LinearLayout.LayoutParams
1. View 의 수직 & 수평 정렬을 설정한다.
- layout_gravity : Orientation 에 설정한 방향에 영향이 없는 gravity 를 이용하여 view 를 배치한다.
(orientation 이 vertical 인 상태에서 layout_gravity 를 bottom 으로 설정하면 bottom 이 무시됨)
[수평 설정인 경우 (Orientation = horizontal)]
[수직 설정인 경우 (Orientation = vertical)]
2. View 의 크기를 가중치로 결정한다.
- layout_weight : 가로 or 세로에 정의된 값만큼 비율로 크기를 결정한다.
Attributes
◼ id
id 는 해당 LinearLayout 을 유일하게 식별할 수 있는 속성이다.
◼ orientation
View 배치를 가로 or 세로로 할지 설정할 수 있는 속성이다.
◼ gravity
Child view 들의 정렬 방식을 설정한다.
gravity = [left | right | center_horizontal | top | center_vertical | bottom | center | fill_horizontal | fill_vertical | fill | clip_horizontal | clip_vertical ] |
◼ layout_gravity
Orientation 에 설정한 방향에 영향이 없는 gravity 를 이용하여 view 를 배치한다.
(상세 설명은 위쪽의 LinearLayout.LayoutParams 를 참조하자)
◼ layout_weight
View 의 크기를 가중치로 결정한다.
(상세 설명은 위쪽의 LinearLayout.LayoutParams 를 참조하자)
◼ weightSum
layout_weight 을 이용할 때 전체 비율을 정확히 명시한다.
◼ baselineAligned & baselineAlignedChildIndex
baselineAligned 이 true 인 상태에서 baselineAlignedChildIndex 로 자식 view 의 index(0부터 시작) 를 지정하면 지정된 view 를 기준으로 나머지 view 들이 정렬된다.
'Android > UI' 카테고리의 다른 글
ListView (1) (0) | 2020.10.28 |
---|---|
RelativeLayout (0) | 2019.11.06 |
FrameLayout (0) | 2019.11.06 |
AbsoluteLayout (0) | 2019.11.06 |
Include & merge tag (0) | 2019.10.31 |
- Total
- Today
- Yesterday
- task 생성
- Intent
- 앱테크
- 안드로이드 서비스
- 무료채굴
- android flag activity
- task
- 앱테크 추천
- 채굴앱
- 리워드앱
- android activity flag
- WEMIX
- 안드로이드 인텐트
- RoomDatabase
- p2e
- notifyDataSetChanged
- mPANDO
- Android Service
- onContextItemSelected
- StringUtils
- BroadcastReceiver
- android task
- StartService
- onCreateContextMenu
- 무료 채굴
- bindservice
- android intent
- 리워드 어플
- M2E
- registerForContextMenu
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |