DBILITY

android include viewBinding 본문

android/kotlin

android include viewBinding

DBILITY 2024. 4. 12. 10:31
반응형

보통하는 Activity에서 하는 것처럼 필요한 Activity에서 하면 된다.

toolbar Layout을 만들고 그걸 Activity에서 include

class MainActivity : AppCompatActivity() {

    private val binding by lazy {
        ActivityMainBinding.inflate(layoutInflater)
    }
    private val bindingToolbar by lazy {
        ToolbarLayoutBinding.inflate(layoutInflater)
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        //enableEdgeToEdge()
        setContentView(binding.root)
        /*ViewCompat.setOnApplyWindowInsetsListener(binding.drawerLayout) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }*/

        setSupportActionBar(bindingToolbar.toolbar)

    }
}

 

반응형

'android > kotlin' 카테고리의 다른 글

android dark mode 비활성화  (0) 2024.04.04
android retrofit2  (0) 2024.04.01
android room database  (0) 2024.03.29
android viewmodel 에서 constructor arguments  (0) 2024.03.29
android migration kapt to ksp  (0) 2024.03.29
Comments