Edge-to-Edge support (XML)

Android is forcing edge-to-edge starting from Android 15. It is not a big deal if you are using Jetpack Compose. Because, you should have been already supporting edge-to-edge and using Scaffolds.

But if you are using XML, you need to manually apply edge-to-edge. And, I will provide below a quick fix if you are using SingleActivity pattern.

class MainActivity: AppCompatActivity {
    private lateinit var binding: ActiviyMainBinding
    
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(binding.root)
    
        enableEdgeToEdge()
    
        ViewCompat.setOnApplyWindowInsetsListener(binding.root) { v, windowInsets ->
            val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())
    
            v.updateLayoutParams<ViewGroup.MarginLayoutParams> {
                leftMargin = insets.left
                bottomMargin = insets.bottom
                rightMargin = insets.right
                topMargin = insets.top
            }
            WindowInsetsCompat.CONSUMED
        }

        .......
    }
}