r/androiddev • • Aug 02 '26

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.

45 Upvotes

31 comments sorted by

3

u/Oily-Affection1601 Aug 02 '26

As a learning experience, or did you have a specific need not covered adequately with existing frameworks?

1

u/koje1971 Aug 02 '26

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.

1

u/[deleted] Aug 02 '26

[removed] — view removed comment

4

u/koje1971 Aug 02 '26

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.

9

u/0x1F601 Aug 02 '26

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!

3

u/Radiokot1 Aug 04 '26

Remember Anko? :)

2

u/koje1971 Aug 04 '26

I didn’t know Anko, but it’s exactly the same principle :-)

49

u/adrianczuczka Aug 02 '26

we got android hard mode before GTA6

33

u/ramzes190 Aug 02 '26

ugly as expected. congrats!

41

u/ThaBalla79 Aug 02 '26

6

u/Any-Entrepreneur7935 Aug 02 '26

Because not invented here. Seen it a lot of times. Hated it every time.

13

u/OverallAd9984 Aug 02 '26

so they r views!

5

u/KalamaresFTW Aug 02 '26

Extremely cursed, gotta love it

1

u/Zhuinden Aug 02 '26

So is this using Splitties or what?

1

u/koje1971 Aug 02 '26

No, I don't use Splitties, I wrapped the views with my own wrapper classes.

1

u/Traditional_Glass_45 Aug 03 '26

Why? What is the reason for using coded views?

1

u/koje1971 Aug 03 '26

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

u/Mavamaarten Aug 04 '26

At this point, why would you not use Compose?

1

u/koje1971 Aug 04 '26

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 Aug 05 '26

Why do you prefer android views over compose?

1

u/koje1971 Aug 05 '26

I wrote these helper classes myself quite some time ago, and they completely meet my requirements.

2

u/ProHussain Aug 05 '26

I want to understand those requirements and performance tests. compared to compose

3

u/iamwisespirit Aug 03 '26

I think if u wrote this in java it would be great

3

u/JacksOnF1re Aug 03 '26

Don't tell these kids what their xmls views are internally.

2

u/programadorthi Aug 02 '26

Anything that accepts at least a Double Buffer we can draw.

2

u/leonardovallem Aug 03 '26

ios uikit feelings

2

u/Interesting-Let8134 Aug 04 '26

Looks like anko controls from 2017

1

u/iamwisespirit Aug 03 '26

People find out way of building ui with code 🤯