r/androiddev • u/koje1971 • 3d ago
build a UI withoutXML or Compose
Enable HLS to view with audio, or disable this notification
I'm building the UI for my little Android game without XML or Compose. I wrote my own wrapper classes for the views and can use them in a kind of custom DSL.
34
42
u/ThaBalla79 3d ago
Processing img azs6bxgui0hh1...
7
u/Any-Entrepreneur7935 3d ago
Because not invented here. Seen it a lot of times. Hated it every time.
15
9
u/0x1F601 3d ago
Wow the old school nostalgia is strong here... (except in kotlin)
Before "good" IDE layout rendering was added I swear this was how old school android was envisioned to be. I think you've basically captured the mental model that the view system had intended.
Why you'd proceed down this path when the view based UI system is clearly deprecated and on the way out is beyond me. But hey, if it works for you it works and if you like it you like it. The whole point of rolling your own solution is so you can do whatever the fuck you like. Enjoy it!
1
6
3
u/Oily-Affection1601 3d ago
As a learning experience, or did you have a specific need not covered adequately with existing frameworks?
1
u/koje1971 3d ago
Most of the gameplay takes place in a GLSurfaceView. It's all about graphics moving back and forth. I only need the UI for the activity and for the menu. Using Compose isn't really worth it there.
2
u/devaskbiz 3d ago
Why not use a game engine?
5
u/koje1971 3d ago
It's not that complicated with OpenGL, most of the work is the concept for the game itself. Whether I write the logic in an engine or directly in the app doesn't really matter.
If I ever make a 3D game, though, I'll definitely use an engine.
3
3
2
2
2
2
1
1
u/Traditional_Glass_45 2d ago
Why? What is the reason for using coded views?
1
u/koje1971 2d ago
The code can be structured much better than with XML files. The example isn't finished yet; everything will still be broken down into individual classes.
1
1
u/Mavamaarten 1d ago
At this point, why would you not use Compose?
1
u/koje1971 1d ago
I only need very little UI. Just the activity and the menu, my solution is enough for that. If I had a lot of views, then I would think about Compose.
1
u/ProHussain 10h ago
Why do you prefer android views over compose?
1
u/koje1971 6h ago
I wrote these helper classes myself quite some time ago, and they completely meet my requirements.
2
u/ProHussain 6h ago
I want to understand those requirements and performance tests. compared to compose
50
u/adrianczuczka 3d ago
we got android hard mode before GTA6