์์ผ๋ก ์๋๋ก์ด๋ ๊ฐ๋ฐ์ ๊ณต๋ถํ๋ฉด์ ๋ฐฐ์ด ๋ด์ฉ๋ค์ ์ ๋ฆฌํด๋ณด๋ ค๊ณ ํ๋ค.
์ค๋์ ์๋๋ก์ด๋ ๊ธฐ๋ณธ ๊ฐ๋
, Jetpack Compose, XML ์ ๋ํด ๊ณต๋ถํ ๋ด์ฉ์ ์ ๋ฆฌํด๋ณด์๋ค.
Google์์ ๋ง๋ ๋ชจ๋ฐ์ผ ์ด์์ฒด์ (OS)
Java, Kotlin์ผ๋ก ๊ฐ๋ฐ ๊ฐ๋ฅ
์ฑ ์คํ ํ๊ฒฝ: ์ค๋งํธํฐ, ํ๋ธ๋ฆฟ, TV, ์จ์ด๋ฌ๋ธ ๋ฑ
๊ตฌ์ฑ์์ : Activity, Fragment, View & ViewGroup, Intent ๋ฑ
์ฐ์ ์ ๊ฐ๋จํ๊ฒ๋ง ์ค๋ช ํ๊ณ ์์ธํ ๊ฒ์ ์์ผ๋ก์ ์์ธํ ๊ณต๋ถ๋ฅผ ํตํด ์ ๋ฆฌํด๋ณด๋๋ก ํ๊ฒ ๋ค (โ'โก'โ)
XML์ ์๋๋ก์ด๋์์ UI๋ฅผ ์ ์ํ๋ ๋ฐฉ๋ฒ์ผ๋ก, HTML๊ณผ ๋น์ทํ ํ๊ทธ ๊ธฐ๋ฐ ํ์์ผ๋ก UI๋ฅผ ๊ตฌ์ฑํ๊ณ , Kotlin(Java) ์ฝ๋์ ๊ฒฐํฉํด ํ๋ฉด์ ๋ง๋ค ์ ์๋ค.
UI๋ฅผ ๋ ์ด์์ ํ์ผ์์ ์ ์
Kotlin(Java)์์ findViewById๋ View Binding์ผ๋ก ์ ๊ทผ
๋ทฐ ๊ณ์ธต์ด ์กด์ฌํ์ฌ UI๊ฐ ํธ๋ฆฌ ๊ตฌ์กฐ๋ก ๋ ๋๋ง
์ฌ๋ฌ ๊ฐ์ ํ์ผ๋ก ๋ถ๋ฆฌ๋์ด ์ฝ๋์ UI๋ฅผ ๋ช
ํํ ๋ถ๋ฆฌ ๊ฐ๋ฅ
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, XML!"
android:textSize="20sp"/>
</LinearLayout>
Jetpack Compose๋ Kotlin ๊ธฐ๋ฐ์ ์ต์ UI ํดํท์ผ๋ก, ๊ธฐ์กด XML ๋ฐฉ์์ด ์๋ ์ ์ธํ UI ๊ฐ๋ฐ์ ๊ฐ๋ฅํ๊ฒ ํด์ฃผ๋ ์๋๋ก์ด๋ ๊ณต์ UI ํ๋ ์์ํฌ์ด๋ค.
์ฝ๋๊ฐ ๊ฐ๊ฒฐํ๊ณ ์ง๊ด์
XML ์์ด Kotlin ์ฝ๋๋ง์ผ๋ก UI ์์ฑ ๊ฐ๋ฅ
@Composable ํจ์๋ก UI๋ฅผ ์ฌ์ฌ์ฉ ๊ฐ๋ฅ
๋ทฐ ๋ฐ์ธ๋ฉ(View Binding) ๋ถํ์ โ findViewById() ์ ์จ๋ ๋จ
@Composable
fun Greeting() {
Text(text = "Hello, Compose!")
}
๐ XML๊ณผ View Binding ์์ด ํ ์ค๋ก UI๋ฅผ ๋ง๋ค ์ ์๋ค!
์ํ ๊ด๋ฆฌ๊ฐ ์ฌ์
ํผํฌ๋จผ์ค ์ต์ ํ (ํจ์จ์ ์ธ UI ๋ ๋๋ง)
๋ถํ์ํ ๋ทฐ ๊ณ์ธต ์ ๊ฑฐ โ ์ฑ๋ฅ ํฅ์
Recomposition ์ต์ ํ โ ๋ณ๊ฒฝ๋ ๋ถ๋ถ๋ง ๋ค์ ๊ทธ๋ฆผ
XML๋ณด๋ค ๋น ๋ฅด๊ฒ UI ๋ ๋๋ง ๊ฐ๋ฅ
๊ธฐ์กด XML๊ณผ ์์ ํ ๋ค๋ฅธ UI ๊ฐ๋ฐ ๋ฐฉ์์ด๊ธฐ์ ComposeView๋ฅผ ์ฌ์ฉํ์ฌ XML๊ณผ Compose ํผํฉ ๊ฐ๋ฅํ์ง๋ง ์์ ํ ์ ํ์ ์ด๋ ต๋ค๋ ๋จ์ ์ด ์กด์ฌ
์์ผ๋ก Jetpack Compose๋ฅผ ๋ ๊น์ด ๊ณต๋ถํ๊ณ , ์ค์ ํ๋ก์ ํธ์์๋ ํ์ฉํด๋ณด๋๋ก ํ๊ฒ ๋ค (o๏พv๏พ)ใ