CS/Android, Kotlin
10
[Android] BottomNavigationView Custom
1
2023.12.03
๋ด๊ฐ ์ปค์คํ
ํด์ผ ๋๋ ๊ฒ ์ํ์ ๊ด๊ณ ์์ด ์์ด์ฝ vector GNB background color ๊ฐ ๊ฐ๊ฒฉ ์ค์ active, deactive ์ํ์ ์์ด์ฝ ์์ ํ
์คํธ ์์ ์ ๋๋ฉ์ด์
์ ๊ฑฐ ์์ด์ฝ ๋ฒกํฐ ์ปค์คํ
→ ๊ทธ๋ฅ menu ๊ด๋ จ xml file์์ ์ค์ ํด์ฃผ๋ฉด ๋จ. GNB Background Color? // ์์ ๋ฃ์ด์ฃผ์ด์ผ ํจ. android:background="@color/Gray_1" app:itemBackground="@color/Gray_1" ๋ ๋ค ์ค์ ํด์ฃผ์ด์ผ ๋จ. ์์ดํ
๋ง ์ค์ ํ๋ฉด ๋น ๊ณต๊ฐ์ด ์๋ ๊ฒฝ์ฐ ์์น ์๋ ์์์ด ๋ณด์ด๊ฒ ๋จ. ์์ด์ฝ & text ์์ ์ปค์คํ
? // ์์ ๋ฃ์ด์ฃผ์ด์ผ ํจ. app:itemIconTint="@color/selector_menu_home_color" a..

[Android] Hilt
2023.05.09
Dependency ํ๋์ ํด๋์ค๊ฐ ๋ค๋ฅธ ํ๋์ ํด๋์ค์ ์์กดํ๋ ๊ฒ์ ์๋ฏธํจ. A ํด๋์ค๊ฐ ๊ฐ์ฒด๋ฅผ ๋ง๋ค๊ธฐ ์ํด B ํด๋์ค๋ฅผ ํ์๋ก ํ ๋ B๋ A์ ์์กด ๋์์ด ๋จ. ์๋ฅผ ๋ค์ด ์๋ฌ๋๋ฅผ ๋ง๋ค๊ธฐ ์ํด ๋๋ ์ฑ์ด ํ์ํจ. ์๋ฌ๋๋ ๋๋ ์ฑ์ ์์กดํ๊ณ ์์. ๋ฐ๋ผ์ ์๋ฌ๋ ← ๋๋ ์ฑ ๊ด๊ณ๊ฐ ๋จ. ์ฌ๊ธฐ์ ๋๋ ์ฑ์ด ์์กด์ ๋์, Dependency๊ฐ ๋จ. Injection ์์ ์๋ฅผ ๊ณ์ ์ฌ์ฉํด์ ์๊ฐํด๋ณด๋ฉด ์๋ฌ๋ ํด๋์ค, ๋๋ ์ฑ ํด๋์ค๊ฐ ์์ ๋ ์๋ฌ๋ ๊ฐ์ฒด๋ฅผ ๋ง๋ค๊ธฐ ์ํด์๋ ๋๋ ์ฑ์ ๊ฐ์ฒด๊ฐ ํ์ํจ. ํ์ง๋ง ์ด ๋๋ ์ฑ ๊ฐ์ฒด๋ฅผ ์๋ฌ๋ ํด๋์ค ๋ด๋ถ์์ ๋ง๋๋ ๊ฒ์ด ์๋๋ผ ์ธ๋ถ์์ ๋ง๋ค์ด์ ๊ฑด๋ค์ฃผ๋ ๋ฐฉ๋ฒ๋ ์์. ์ด๋ ๊ฒ ์ธ๋ถ์์ ์์กด๊ด๊ณ๊ฐ ์๋ ๋์์ ๊ฐ์ ธ์ค๋ ๊ฒ์ ์์กด์ฑ(Dependency)์ ์ธ๋ถ์์ ์ฃผ์
(Inje..
[Android] Base Activity, Fragment
2023.04.16
๋ฐฑ์
์ฉ๋๋ก ์์ฑ import android.os.Bundle import androidx.annotation.LayoutRes import androidx.appcompat.app.AppCompatActivity import androidx.databinding.DataBindingUtil import androidx.databinding.ViewDataBinding import androidx.lifecycle.ViewModel abstract class BaseActivity(@LayoutRes val layoutRes: Int) : AppCompatActivity() { /*@LayoutRes abstract fun getLayoutRes(): Int*/ abstract val viewModel: ..

[Android] OKHttp3๋ฅผ ์ฌ์ฉํ ํค๋ ์ถ๊ฐ, Retrofit2๋ฅผ ์ฌ์ฉํ http ํต์
2023.04.16
OKHttp3, Retrofit2 square์ฌ์์ ๊ฐ๋ฐํ ์คํ์์ค ๋ผ์ด๋ธ๋ฌ๋ฆฌ. http ํด๋ผ์ด์ธํธ๋ก ์ฝ๊ฒ request, response๊ฐ ๊ฐ๋ฅํ๊ฒ ํจ. Retrofit ํน์ง ์ฑ๋ฅ์ด ์ข์. (Volley, AsyncTask์ ๋นํด) annotation์ ์ฌ์ฉํด HTTP ์์
์ ํ๋ ๋ฉ์๋๋ฅผ ์ ์ํ๊ธฐ ๋๋ฌธ์ ๊ฐ๋ฐ์๋ค์ด ํ์๋ฅผ ์์ฝ๊ฒ ์์๋ณผ ์ ์์. (๊ฐ๋
์ฑ ๐) ์ฃผ๊ณ ๋ฐ๋ ๋ฐ์ดํฐ(JSON)๋ฅผ ์๋์ผ๋ก ํ์ฑํด์ฃผ๊ธฐ ๋๋ฌธ์ ์ ์ง๋ณด์๊ฐ ํธ๋ฆฌํจ. ์บ์ฑ์ด ๋ถ๊ฐ๋ฅํจ image loading์ด ๋ถ๊ฐ๋ฅํ์ฌ glide์ ๊ฐ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํด์ผ ํจ. OKHttp3 - ๋ด๊ฐ ์ฌ์ฉํ ๋ถ๋ถ ๋ด๊ฐ ์ฌ์ฉํ ๋ถ๋ถ์ ํด๋ผ์ด์ธํธ์์ request๋ฅผ ๋ ๋ฆด ๋ ํค๋๋ฅผ ๋ฃ์ด์ฃผ๋๋ก ๋ง๋ค์์. // header ์ถ๊ฐ private val ok..
[Android] Custom View
2023.04.15
๋ฉด์ ๊ธฐ๋ก์ฉ Custom View ์ ๋ฆฌ ์ปค์คํ
๋ทฐ ์ฌ์ฉํ๋ ๋ชฉ์ ์์ ๋ง์ถค ๋ ๋๋ง ๋ ๋ทฐ ์ ํ์ ๋ง๋ค ์ ์์ ๊ธฐ์กด view ๊ตฌ์ฑ์์ ๊ทธ๋ฃน์ ์๋ก์ด ๋จ์ผ ๊ตฌ์ฑ์์๋ก ๋ง๋ค ์ ์์ ํค ๋๋ฆ๊ณผ ๊ฐ์ ๋ค๋ฅธ ์ด๋ฒคํธ๋ฅผ ํ์ธํ๊ณ ๋ง์ถค ๋ฐฉ์์ผ๋ก ์ฒ๋ฆฌํ ์ ์์ ์ฌ์ฌ์ฉ ๊ฐ๋ฅ ๊ตฌํ ๋ฐฉ๋ฒ attrs.xml ์ ์ : ์ปค์คํ
๋ทฐ์์ ์ฌ์ฉํ๊ณ ์ ํ๋ ์์ฑ์ด ์๋ค๋ฉด attrs.xml์ ์ ์ํด์ค res > values ํด๋์ attrs.xml ์ ์์ฑ declare-styleable ํ๊ทธ๋ฅผ ์์ฑ ํ name์๋ ์ปค์คํ
๋ทฐ ํด๋์ค๋ช
์ ์
๋ ฅ attr ํ๊ทธ๋ฅผ ์์ฑํด์ name์๋ ์์ฑ๋ช
, format์๋ ์์ฑ์ type์ ์
๋ ฅํด์ค // ์์ ์ปค์คํ
๋ทฐ ํด๋์ค ์์ฑ View ํด๋์ค๋ฅผ ์์ ๋ฐ๋ ํด๋์ค๋ฅผ ์์ฑ, ์ด๋์ ํด๋์ค๋ช
์ ์ attrs..
[Android] Data Binding
2023.04.15
๋ฉด์ ๊ธฐ๋ก์ฉ Data Binding ์ ๋ฆฌ Data Binding์ xml ํ์ผ์ data๋ฅผ ์ฐ๊ฒฐํด์ ์ฌ์ฉํ ์ ์๋๋ก ๋์์ฃผ๋ ๊ฒ์ผ๋ก MVVM ํจํด์ ๊ตฌํํ ๋ LiveData์ ํจ๊ป ๊ฑฐ์ ํ์์ ์ผ๋ก ์ฌ์ฉ๋จ. ๋ฐ์ดํฐ ๋ฐ์ธ๋ฉ์ ์ฅ์ ์ ๊ธ๋ฃจ ์ฝ๋๋ฅผ ์ค์ผ ์ ์์. ๋ ์ด์์๊ณผ ๋ฐ์ดํฐ๋ฅผ ์ฐ๊ฒฐํ๊ธฐ ์ํ ์ฝ๋๋ค์ ์ค์ผ ์ ์์. ๋ด๊ฐ ์ฌ์ฉํ๋ ๋ถ๋ถ // ... // ... ์ ์ฒด๋ฅผ ํ๊ทธ๋ก ๊ฐ์ธ์ฃผ๊ณ ํ๊ทธ ์ฌ์ด์ ํ๊ทธ๋ก ๋ฐ์ดํฐ ๋ฐ์ธ๋ฉ์ ํ์ํ ๋ณ์๋ฅผ ์ ์ธํด์ค. ๋๋ viewmodel์ ๋ฐ์ดํฐ ๋ฐ์ธ๋ฉ์ ํ์ํ ๋ณ์๋ก ์ฌ์ฉํ ์์ ์ด์ด์ ๋ค์๊ณผ ๊ฐ์ด ํด์ค. class MainActivity : BaseActivity(R.layout.activity_main) { override val viewModel by viewModels..