2024. 3. 19. 17:41, ๐ฑAndroid Study
๋ฐ์ํ
1. ๋ ์ด์์(Layout)
- ๋ ์ด์์์ด๋ ViewGroup์ ํ์ ํด๋์ค๋ก์, ํฌํจ๋ View๋ฅผ ์ ๋ ฌํ๋ ๊ธฐ๋ฅ
01. Linear Layout
- ์ปจํ ์ด๋์ ํฌํจ ๋ ์์ ๋ทฐ๋ค์ ์ํ ๋๋ ์์ง์ผ๋ก ์ผ๋ ฌ ๋ฐฐ์นํ๋ ๋ ์ด์์
- ๊ฐ์ฅ ๋จ์ํ๊ณ ์ง๊ด์ ์ด๋ฉฐ ์ฌ์ฉ๋น๋๊ฐ ๋์
- Orientation : Vertical(Child๋ฅผ ์์์ ์๋๋ก), Horizontal(child๋ฅผ ์ผ์ชฝ์์ ์ค๋ฅธ์ชฝ์ผ๋ก)
- LinearLayout์ ์์(Children)์ผ๋ก ๋ฐฐ์น๋๋ View์์ ฏ๋ค์ ์ค์ง ํ ๋ฐฉํฅ์ผ๋ก๋ง ๋ฐฐ์น
- ์์ ฏ์ ํฌ๊ธฐ (๋์ด ๋๋ ๋๋น) ์ ๊ด๊ณ์์ด ํ ์ค๋ก๋ง ๋ฐฐ์ด
๊ฐ๋ก ๋ฐฉํฅ์ผ๋ก ๋ฐฐ์น ๋ ๋๋ ๊ฐ๋ก๋ก ํ ์ค(onlyonerow), ์ธ๋ก ๋ฐฉํฅ์ผ๋ก ๋ฐฐ์น๋ ๋๋ ์ธ๋ก๋ก ํ ์ค(onlyonecolumn) - LinearLayout์ ์์๋ค์ ์ค์ฒฉ(overlap)๋์ง ์๊ณ ,์ง์ ํ ๋ฐฉํฅ์ผ๋ก ์์ด๋(stacked)ํํ๋ก ํ์
๐ก LayoutWeight
- ์์(Children)๋ค์ด ๋ฐฐ์น ๋ ๋, ์ ์ฒด ์์ญ ๋๋น ๋น์จ์ ๊ฐ๋ ์ผ๋ก ์ง์ ํ ์ ์๋ Weight(๊ฐ์ค์น)๋ฅผ ์ค์ ๊ฐ๋ฅ
- (์) ์ ์ฒด ํฌ๊ธฐ๋ฅผ 10์ผ๋ก ๋ณธ๋ค๋ฉด, ์ฒซ ๋ฒ์งธ View ์์ ฏ์ 3, ๋ ๋ฒ์งธ View ์์ ฏ์ 7์ ์์ญ์ ์ฐจ์งํ๋๋ก ๋ง๋ค ์ ์์
- android:layout_weight = "3"
02. Relative Layout
- ๋ทฐ๋ฅผ ์๋ก ๊ฐ์ ์์น ๊ด๊ณ๋ ์ปจํ ์ด๋์์ ์์น ๊ด๊ณ๋ฅผ ์ง์ ํ์ฌ ๋ฐฐ์นํ๋ ๋ ์ด์์
- 1. ์์(Children) View์์ ฏ๋ค์ด ์๋ก ๊ฐ์ ์๋์ ๋ฐฐ์น ๊ด๊ณ์ ๋ฐ๋ผ ํ๋ฉด์ ํ์ ๋ ์์น๊ฐ ๊ฒฐ์
- (์) B๋ A์ ์ค๋ฅธ์ชฝ์ ํ์ : B toRightOf A
(์) D๋ฅผ C์ ์๋์ชฝ์ ํ์ : D below C - 2. View ์์ ฏ๋ค์ ํฌํจํ๋ ๋ถ๋ชจ(Relative Layout) ์์ฒด๊ฐ ์๋์ ์์น์ ๊ธฐ์ค์ ์ผ๋ก ์ฌ์ฉ ๋ ์๋ ์์
(์) ์์(Children)๋ค์ '์๋์ ์ธ' ๋ฐฐ์น ๊ธฐ์ค์ ์ง์ ํ์ง ์๋๋ค๋ฉด, RelativeLayout ๋ด๋ถ์์ ์ค์ฒฉ(Overlap)๋์ด ํ์ - ์ฌ์ฉ ์์
- android:layout_toLeftOf="@id/buttion1"
- android:layout_alignParentLeft="true"
์์ฑ | ์ค๋ช | |
์์ ๊ฐ ๊ธฐ์ค |
layout_toLeftOf | ๋ทฐ(View)๋ฅผ ๊ธฐ์ค ๋ทฐ(Anchor View)์ ์ผ์ชฝ(Left)์ ๋ฐฐ์น |
layout_above | ๋ทฐ(View)๋ฅผ ๊ธฐ์ค ๋ทฐ(Anchor View)์ ์(Above)์ ๋ฐฐ์น | |
layout_roRightOf | ๋ทฐ(View)๋ฅผ ๊ธฐ์ค ๋ทฐ(Anchor View)์ ์ค๋ฅธ์ชฝ(Right)์ ๋ฐฐ์น | |
layout_below | ๋ทฐ(View)๋ฅผ ๊ธฐ์ค ๋ทฐ(Anchor View)์ ์๋(Below)์ ๋ฐฐ์น | |
layout_toStartOf | ๋ทฐ(View)๋ฅผ ๊ธฐ์ค ๋ทฐ(Anchor View)์ ์์(Start)์ ๋ฐฐ์น | |
layout_toEndOf | ๋ทฐ(View)๋ฅผ ๊ธฐ์ค ๋ทฐ(Anchor View)์ ๋(End)์ ๋ฐฐ์น | |
layout_alignLeft | ๋ทฐ(View)์ ์ผ์ชฝ(Left)์ ๊ธฐ์ค ๋ทฐ(View)์ ์ผ์ชฝ(Left)์ ๋ง์ถค. | |
layout_alignTop | ๋ทฐ(View)์ ์(Top)๋ฅผ ๊ธฐ์ค ๋ทฐ(View)์ ์(Top)์ ๋ง์ถค. | |
layout_alignRight | ๋ทฐ(View)์ ์ค๋ฅธ์ชฝ(Right)๋ฅผ ๊ธฐ์ค ๋ทฐ(View)์ ์ค๋ฅธ์ชฝ(Right)์ ๋ง์ถค. | |
layout_alignBottom | ๋ทฐ(View)์ ์๋(Bottom)๋ฅผ ๊ธฐ์ค ๋ทฐ(View)์ ์๋(Bottom)์ ๋ง์ถค. | |
layout_alignBaseline | ๋ทฐ(View)์ ํฐํธ ๊ธฐ์ค์ (Baseline)์ ๊ธฐ์ค ๋ทฐ(View)์ ํฐํธ ๊ธฐ์ค์ (Baseline)์ ๋ง์ถค. | |
๋ถ๋ชจ ๊ธฐ์ค |
layout_alignParentLeft | ๋ทฐ(View)๋ฅผ ๋ถ๋ชจ(Parent) ์์ญ ๋ด์์ ์ผ์ชฝ(Left)์ ๋ฐฐ์น |
layout_alignParentTop | ๋ทฐ(View)๋ฅผ ๋ถ๋ชจ(Parent) ์์ญ ๋ด์์ ์์ชฝ(Top)์ ๋ฐฐ์น | |
layout_alignParentRight | ๋ทฐ(View)๋ฅผ ๋ถ๋ชจ(Parent) ์์ญ ๋ด์์ ์ค๋ฅธ์ชฝ(Right)์ ๋ฐฐ์น | |
layout_alignParentBottom | ๋ทฐ(View)๋ฅผ ๋ถ๋ชจ(Parent) ์์ญ ๋ด์์ ์๋์ชฝ(Bottom)์ ๋ฐฐ์น | |
layout_centerHorizontal | ๋ทฐ(View)๋ฅผ ๋ถ๋ชจ(Parent) ์์ญ์ ๊ฐ๋ก ๋ฐฉํฅ ๊ฐ์ด๋ฐ ๋ฐฐ์น. | |
layout_centerVertical | ๋ทฐ(View)๋ฅผ ๋ถ๋ชจ(Parent) ์์ญ์ ์ธ๋ก ๋ฐฉํฅ ๊ฐ์ด๋ฐ ๋ฐฐ์น. | |
layout_centerInParent | ๋ทฐ(View)๋ฅผ ๋ถ๋ชจ(Parent) ์์ญ์ ์ ์ค์(center)์ ๋ฐฐ์น. | |
layout_alignParentStart | ๋ทฐ(View)๋ฅผ ๋ถ๋ชจ(Parent) ์์ญ์ ์์ ์ง์ (Start)์ ๋ฐฐ์น. | |
layout_alignParentEnd | ๋ทฐ(View)๋ฅผ ๋ถ๋ชจ(Parent) ์์ญ์ ๋ ์ง์ (End)์ ๋ฐฐ์น. |
03. Table Layout
- ํ ํ์์ผ๋ก ์ฐจ์ผ๋๋ฅผ ๋ฐฐ์นํ๋ ๋ ์ด์์
- ์์(Children) View ์์ ฏ๋ค์ ํ ์ด๋ธ(ํ๊ณผ ์ด๋ก ๊ตฌ์ฑ)๋ก ๋๋์ด ํ์
- ํ๋ฅผ ๊ตฌ์ฑํ๋ ํ์ ๊ฐ์๋งํผ TableRow๋ฅผ ํฌํจํ๊ณ , TableRow๋ ๊ฐ ํ์ ํฌํจ๋ ์ (View)์ ํฌํจ
- ์ฃผ์ ์์ฑ
- stretchColumns: ๋๋ฆด ์ด์ ์ง์
- "*" : ๋ชจ๋ ์ด์ ๋์ฌ์ ๋ฐฐ์น
- "1, 2" : 1์ด(์ผ์ชฝ์์ 2๋ฒ์งธ)๊ณผ 2์ด(์ผ์ชฝ์์ 3๋ฒ์งธ)๋ฅผ ๋์ฌ์ ๋ฐฐ์น - TableRow
- ์ ํด์ง ๊ท์น์ ๋ฐ๋ผ ํฌ๊ธฐ๊ฐ ๊ฒฐ์ ๋๋ฏ๋ก, layout_width/height๋ฅผ ์ง์ ํ ํ์๊ฐ ์์
- layout_height๋ ํญ์ wrap_content
- layout_width๋ ํญ์ match_parent
04. Frame Layout
- ์ปจํ ์ด๋์ ํฌํจ๋ ๋ทฐ๋ค์ ์ ๋ถ ์ข์๋จ์ ๋ฐฐ์นํ๋ ๋ ์ด์์
- ํ๋์ ์์ View์์ ฏ๋ง ํ์ ํ ๋ ์ฌ์ฉ
(์ฌ๋ฌ๊ฐ์ ๋ทฐ(View) ์์ ฏ๋ค์ ์ค์ฒฉํ๊ณ , ๊ทธ ์ค ํ๋๋ฅผ ์ ๋ฉด์ ํ์ํ ๋. ํฌ์คํธ์ ์์ ๋ฎ๋ ๋๋) - Frame Layout์ ์ฌ๋ฌ View์์ ฏ์ ์์์ผ๋ก ์ถ๊ฐํ๋ฉด ๊ฒน์ณ์ง ํํ(Overlap)๋ก ํ์๋๋ฉฐ,
๊ฐ์ฅ ์ต๊ทผ์ ์ถ๊ฐ๋ View์์ ฏ์ด ๊ฐ์ฅ ๋งจ ์, ์์ (ontop) ์ ํ์
05. Constraint Layout
- ์ ์ฝ ์กฐ๊ฑด์ ์ฌ์ฉํด ํ๋ฉด์ ๊ตฌ์ฑํ๋ ๋ ์ด์์
- ๋ณต์กํ ๋ ์ด์์์ ๋จ์ํ ๊ณ์ธต๊ตฌ์กฐ๋ฅผ ์ด์ฉํด ํํ ํ ์ ์๋ ViewGroup
- ํ์ View๋ค๊ณผ์ ๊ด๊ณ๋ฅผ ์ ์ํด์ ๋ ์ด์์์ ๊ตฌ์ฑํ๋ ๊ฑด RelativeLayout๊ณผ ๋น์ทํ์ง๋ง ๋ณด๋ค ์ ์ฐ, ๋ค์
- RelativeLayout์์ ๋ถ๊ฐ๋ฅํ๋ ์์ ๋ทฐ๊ฐ์ ์ํธ ๊ด๊ณ ์ ์ ๊ฐ๋ฅ
- ๋ทฐ ๊ณ์ธต์ ๊ฐ๋จํ๊ฒ ํ ์ ์์ด ์ ์ง๋ณด์๋ ์ข๊ณ ์ฑ๋ฅ๋ ์ข์
๐ก์์ ฏ์ ํฌ๊ธฐ ์ค์
- ๋ฆฌ์ฌ์ด์ฆ ํธ๋ค (ResizeHandle) ์ด์ฉํ๊ธฐ
- ์์ ฏ์ ํด๋ฆญํ๋ฉด ๋ค ๋ชจ์๋ฆฌ์ ํธ๋ค์ด ์๊ฒจ, ๋ง์ฐ์ค๋ก ๋๋๊ทธํ์ฌ ํฌ๊ธฐ๋ฅผ ์ค์
- ๋๋๊ทธํด์ ํฌ๊ธฐ๋ฅผ ์กฐ์ ํ๋ฉด ์ค๋ฅธ์ชฝ ์์ฑ์ฐฝ์ layout_width, layout_height ๋ฅผ ์ ๋ ฅํด์ ์ค์ ๊ฐ๋ฅ - ์ง์ ๊ฐ์ ์
๋ ฅํ์ฌ ์ค์ ํ๊ธฐ
- ์ค๋ฅธ์ชฝ ์์ฑ์ฐฝ์ layout_width, layout_height ๋ฅผ ์ ๋ ฅํด์ ์ค์ ๊ฐ๋ฅ - wrap_content : ์์ ฏ ๋ด๋ถ์ ์๋ ์ปจํ ์ธ ์ ๋ฑ ๋ง๊ฒ ๊ธธ์ด ๊ฒฐ์
- match_constraint : ๋๋น๋ฅผ ๊ฝ ์ฑ์ฐ๋๋ก ๋์ด๋จ
๐ก ์์ ฏ์ ์๋ ์ ๋ ฌ
- ์ฌ์ด๋ ํธ๋ค(SideHandle) ์ด์ฉํ๊ธฐ
- ์์ ฏ์ ํด๋ฆญํ๋ฉด ๊ฐ ๋ณ์ ๊ฐ์ด๋ฐ ํธ๋ค์ด ์์
- ์์ ฏ์ด ๋ค๋ฅธ ์์ ฏ ๋๋ ํ๋ฉด์ ๊ฒฝ๊ณ์ ๋ํด ์ด๋ป๊ฒ ์ ๋ ฌ๋ ์ง ๋๋๊ทธํ์ฌ ์ฐ๊ฒฐ ๋ฐ ์ง์ ๊ฐ๋ฅ - ์ฐ์ธก ์์ฑ์ฐฝ์์ ์ ๋ ฌ๊ฐ ์ค์ ๊ฐ๋ฅ
๐ก ์์ ฏ ๋ด ํ ์คํธ์ ์์น๋ก ์ ๋ ฌ
- ๋ฒ ์ด์ค๋ผ์ธ ํธ๋ค(BaselineHandle) ์ด์ฉํ๊ธฐ
- ์์ ฏ์ ํด๋ฆญํ๊ณ ๋ง์ฐ์ค๋ฅผ ๊ฐ์ ธ๊ฐ๋ฉด ์ข์ธก ํ๋จ์ 'ab' ๋ผ๋ ๋ฒ ์ด์ค๋ผ์ธ ์์ด์ฝ์ด ์์
- ํด๋ฆญํ๋ฉด ์์ ฏ์ ํ ์คํธ ํ๋จ์ ๋ฒ ์ด์ค ๋ผ์ธ ํธ๋ค์ด ๋ณด์
- ์ด ๋ฒ ์ด์ค ๋ผ์ธ ํธ๋ค์ ํด๋ฆญํ์ฌ ๋ค๋ฅธ ์์ ฏ์ ํ ์คํธ์ ์ฐ๊ฒฐํ๋ฉด, ํ ์คํธ์ ํ๋จ์ด ์ผ์นํ๋๋ก ์ ๋ ฌ
๐ก Constraint ํด๋ฐ ์ฌ์ฉํ๊ธฐ
- 1. Autoconnect
- ์ผ๋๋ฉด ์์ ฏ์ ๋ฐฐ์นํ ๋ ์๋์ผ๋ก ์ด์ํ ์์ ฏ๊ณผ ๊ด๊ณ๋ฅผ ๋งบ์ด์ค - 2. Clear All Constraints
- ๋ชจ๋ ๊ด๊ณ๋ฅผ ์ญ์ - 3. Infer constraints
- ๋ ์ด์์๋ด ๋ฐฐ์น๋ ๋ชจ๋ ์์ ฏ์ ํ์ฌ ์์น๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ๊ด๊ณ๋ฅผ ๋งบ์ด์ค - 4. Default Margins
- ์์ ฏ ๊ฐ์ ๊ธฐ๋ณธ ๋ง์ง ๊ฐ์ ์ง์ - 5. Guidelines
- ์ํ,์์ง ๊ฐ์ด๋๋ผ์ธ์ ๋ง๋ฆ
- ์์ ฏ์ ์ด ๊ฐ์ด๋๋ผ์ธ์ ๊ธฐ์ค์ผ๋ก ์ ๋ ฌ ํ ์ ์์
๐ก ์์ฑ์ฐฝ
- 1. Margin
- layout_width๊ฐ match_constraint์ด๋ฏ๋ก ์ข์ฐ ์ฌ๋ฐฑ 8๋ง ์๊ณ ๋จ์ ์ ์ฒด๋ฅผ ์์ ฏ์ด ์ฐจ์ง์ค - 2. Aspect Ratio
- ํด๋ฆญํ๋ฉด ์์ ฏ์ ๊ฐ๋ก ์ธ๋ก๋น์จ์ ์ง์ - 3. Wrap Content
- ๋ถ๋ฑํธ ์ธ ๊ฐ(<<<)๋ก ๋ ๋ชจ์์ wrap_content๋ก ์ง์ ๋์ด ์์์ ๋ํ๋ - 4. Any Size
- ํฑ๋๋ชจ์์ ์ต๋ํ์ ๋๋น๋ฅผ ์ฐจ์ง, match_constraint๋ก ์ง์ ๋์ด ์์ - 5. ์ ์
- ์๋ฌด ๊ด๊ณ๊ฐ ์๋ ๊ฒฝ์ฐ - 6. Horizontal Bias
- ์์ ฏ์ ์ข์ฐ์ธก ์์น ๋น์จ์ ์ง์
- ๋๋๊ทธํด์ ๋ฐ๊ฟ ์ ์์
2. Margin / Padding / Gravity
01. Margin
- ๋ทฐ์ ๋ค๋ฅธ ๋ทฐ(์ปจํ ์ด๋) ๊ฐ์ ๊ฐ๊ฒฉ
- android:layout_margin="" : ์ํ์ข์ฐ๋ก ๋์ผํ ๋ง์ง ์ค์ ์์ ์ฌ์ฉ๋๋ ์์ฑ
- layout_marginLeft, layout_marginRight, layout_marginTop, layout_marginBottom
: 4๋ฐฉํฅ์ ๋ง์ง์ ๊ฐ๊ธฐ ๋ค๋ฅด๊ฒ ์ค์ ํ ๋ ์ฌ์ฉ๋๋ ์์ฑ
02. Padding
- ๋ทฐ ์์ ๋ด๋ถ์ฌ๋ฐฑ
- android:padding="": ์ํ์ข์ฐ๋ก ๋์ผํ ํจ๋ฉ ์ค์ ์์ ์ฌ์ฉ
- paddingLeft, paddingRight, paddingTop, paddingBottom**
: ๋ฐฉํฅ์ ๋ง์ง์ ๊ฐ๊ธฐ ๋ค๋ฅด๊ฒ ์ค์ ํ ๋ ์ฌ์ฉ๋๋ ์์ฑ**
03. Gravity
- android:gravity="" ๋ก ์ฌ์ฉ
- gravity: ํด๋น ๋ทฐ์์ ๋ด์ฉ๋ฌผ ์์น์ ๋ํ ์ ๋ ฌ๋ฐฉ์์ ์ง์
- layout_gravity: ๋ถ๋ชจ ๋ทฐ ์์์ ํด๋น ๋ทฐ์ ์ ๋ ฌ ๋ฐฉ์ ์ง์
- ๊ฐ๋ฅํ ๊ฐ๋ค (๋ถ๋ชจ ๋ทฐ ์์์ ํด๋น ๋ทฐ์ ์ ๋ ฌ ๋ฐฉ์ ์ง์ ๋ง)
- BOTTOM : ๋ถ๋ชจ ๋ทฐ์์ ์๋ ์ชฝ์ ์์น์ํด
- CENTER : ๋ถ๋ชจ ๋ทฐ์ ์ค์์ ์์น์ํด
- CENTER_HORIZONTAL : ๋ถ๋ชจ ๋ทฐ์ ์ํ๊ธฐ์ค์ผ๋ก ์ค์์ ์์น์ํด
- CENTER_VERTICAL : ๋ถ๋ชจ ๋ทฐ์ ์์ง๊ธฐ์ค์ผ๋ก ์ค์์ ์์น์ํด
- END : ๋ถ๋ชจ ๋ทฐ์์ ํ ์คํธ ๋ฐฉํฅ์ ๋(ํ๊ธ์ด๋ ์์ด์ ๊ฒฝ์ฐ๋ ์ค๋ฅธ์ชฝ)์ ์์น์ํด
- LEFT : ๋ถ๋ชจ ๋ทฐ์์ ์ผ์ชฝ์ ์์น์ํด
- RIGHT : ๋ถ๋ชจ ๋ทฐ์์ ์ค๋ฅธ์ชฝ์ ์์น์ํด
- TOP : ๋ถ๋ชจ ๋ทฐ์์ ์์ชฝ์ ์์น์ํด
3. Style,Theme
01. Style
- View ๋๋ ์ฐฝ์ ๋ชจ์๊ณผ ํ์์ ์ง์ ํ๋ ์์ฑ ๋ชจ์
- ๋์ด, ํจ๋ฉ, ๊ธ๊ผด ์์, ๊ธ๊ผดํฌ๊ธฐ, ๋ฐฐ๊ฒฝ์ ๋ฑ์ ์์ฑ์ ์ง์
- ๋ ์ด์์์ ์ง์ ํ๋ XML๊ณผ ๋ณ๊ฐ์ธ XML๋ฆฌ์์ค์ ์ ์๋จ
- Android์ ์คํ์ผ์ ์น ๋์์ธ์ cascading์คํ์ผ ์ํธ์ ์ ์ฌํ ์ฒ ํ์ ๊ณต์
- ์ด๋ฅผ ํตํด ์ฝํ ์ธ ์ ๋์์ธ์ ๊ตฌ๋ถ
02. Theme (ํ ๋ง)
- ๊ฐ๋ณView ๊ฐ ์๋๋ผ ์ ์ฒด Activity ๋๋ ์ ํ๋ฆฌ์ผ์ด์ ์ ์ ์ฉ๋๋ ์คํ์ผ
- ์คํ์ผ์ด ํ
๋ง๋ก ์ ์ฉ๋ ๊ฒฝ์ฐ, ์กํฐ๋นํฐ ๋๋ ์ ํ๋ฆฌ์ผ์ด์
์ ํฌํจ๋ ๋ชจ๋ ๋ทฐ๊ฐ ์์ ์ด ์ง์ํ๋ ์คํ์ผ ์์ฑ์ ์ ์ฉ
(์) ์กํฐ๋นํฐ์ ํ ๋ง์ ๋์ผํ CodeFont์คํ์ผ์ ์ ์ฉํ๋ค๋ฉด,
ํด๋น ์กํฐ๋นํฐ์ ํฌํจ๋ ๋ชจ๋ ํ ์คํธ์ ๋ น์์ ๊ณ ์ ํญ ๊ธ๊ผด์ด ์ ์ฉ
์ค์ต
๋๋ณด๊ธฐ


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#540BA6"
tools:context=".MainActivity">
<LinearLayout
android:background="#E4C5FF"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button1"
/>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button2"
android:layout_gravity="center"
/>
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button3"
android:layout_gravity="right"
/>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#AB78B6"
android:layout_margin="10dp">
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button4"
android:layout_toLeftOf="@id/button5"
android:layout_marginRight="20dp"
/>
<Button
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button5"
android:layout_alignParentRight="true"
/>
<Button
android:id="@+id/button6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button6"
android:layout_below="@id/button4"
android:layout_marginLeft="10dp"
/>
</RelativeLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:background="#E4C5FF"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
<Button
android:id="@+id/button7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button7"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<Button
android:id="@+id/button8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Button8"
app:layout_constraintStart_toEndOf="@id/button7"
app:layout_constraintTop_toTopOf="@id/button7"
app:layout_constraintBottom_toBottomOf="@id/button7"
android:layout_marginLeft="20dp"
/>
<Button
android:id="@+id/button9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text="Button9"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button7"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- </LinearLayout>-->
</LinearLayout>
๋ฐ์ํ
๐ฌ C O M M E N T