MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContentView(R.layout.activity_main)
binding = ActivityMainBinding.inflate(layoutInflater)
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
insets
}
}
}
here is the mainactivity.kt and after watching a tutorial i saw that they have “setcontentview(R.layout.activity_main)” is changed to ” setcontentview(binding.root) ”
I dont know how to change. little help pliz
I tried to change ” ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main))”( R.id.main)
to binding.root and it doesn’t work
New contributor
yum evendro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.