리μ¬μ΄ν΄λ¬λ·°μ μμ΄ν μ¬μ΄μ¦κ° μ΄μνλ€.
κ° μμ΄ν λ μ΄μμμ ConstraintLayout μμ ꡬμ±λμ΄ μμλ€. μ΅μμ λ μ΄μμμ android:layout_width="match_parent" κ° λ¨Ήνμ§ μμμ λ§κ°μ§λ κ²μΌλ‘ μΆμΈ‘νλ€. ν μ€νΈλ§ λ°λ μμ΄ν , μΈλ€μΌλ λ°λ μμ΄ν μ΄ λ κ°μ§ νμ μ λ·°νλκ° μλλ° μ μΈλ€μΌ λ°λ μμ΄ν λ§ μ΄λ¬λ κ±΄μ§ κ³ λ―Ό.
λ΅μ μ°Ύμ.
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) : ViewHolder {
val inflater = LayoutInflater.from(parent.context)
return when(viewType) {
VIEW_TEXT -> TextHolder(
ItemTxtBinding.inflate(inflater, parent, false)
)
VIEW_THUMBNAIL -> ThumnailHolder(
ItemThmbnlBinding.inflate(inflater) // <--λ¬Έμ μμΈ λ°κ²¬
)
}
}
LayoutInflaterμ κ΄ν΄ μ΄ν΄λ³΄κ³ κ°κΈ°.
https://medium.com/vingle-tech-blog/android-layoutinflater-b6e44c265408
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) : ViewHolder {
val inflater = LayoutInflater.from(parent.context)
return when(viewType) {
VIEW_TEXT -> TextHolder(
ItemTxtBinding.inflate(inflater, parent, false)
)
VIEW_THUMBNAIL -> ThumnailHolder(
ItemThmbnlBinding.inflate(inflater, parent, false) // <--λ¬Έμ ν΄κ²°
)
}
}