Junior — Middle
Is it possible to implement a user interface without using XML markup?
sobes.tech AI
Answer from AI
Yes, the user interface in Android can be implemented without XML layout, using programming code in Java or Kotlin. Instead of describing the UI in XML, all elements are created and configured dynamically in code.
Example in Kotlin:
val button = Button(this).apply {
text = "Click me"
setOnClickListener { /* handle click */ }
}
setContentView(button)
This approach is useful if the interface needs to change dynamically or be built depending on conditions during runtime.