Reputation: 39
When developing for the android. Are we bound to using xml layout files? (In res\layout ) Or can we skip them entirely and programmatically create and implement our layouts for UI?
Upvotes: 0
Views: 66
Reputation: 2473
Sure you can.
In an Activity
you can use setContentView(View view)
instead of setContentView(int resource)
in the onCreate()
callback.
If you use a Fragment
you can programmatically create a View
instead of inflating a resource. This has to be done in the onCreateView()
callback of the fragment
Upvotes: 1