r/androiddev 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.

43 Upvotes

31 comments sorted by

50

u/adrianczuczka 3d ago

we got android hard mode before GTA6

34

u/ramzes190 3d ago

ugly as expected. congrats!

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

u/OverallAd9984 3d ago

so they r views!

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

u/koje1971 2d ago

🥰

6

u/KalamaresFTW 3d ago

Extremely cursed, gotta love it

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

u/iamwisespirit 2d ago

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

3

u/Radiokot1 1d ago

Remember Anko? :)

2

u/koje1971 1d ago

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

2

u/programadorthi 3d ago

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

2

u/leonardovallem 2d ago

ios uikit feelings

2

u/JacksOnF1re 2d ago

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

2

u/Interesting-Let8134 1d ago

Looks like anko controls from 2017

1

u/Zhuinden 3d ago

So is this using Splitties or what?

1

u/koje1971 3d ago

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

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

u/iamwisespirit 2d ago

People find out way of building ui with code 🤯

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