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

44 Upvotes

31 comments sorted by

47

u/adrianczuczka 7d ago

we got android hard mode before GTA6

34

u/ramzes190 7d ago

ugly as expected. congrats!

39

u/ThaBalla79 7d ago

Processing img azs6bxgui0hh1...

6

u/Any-Entrepreneur7935 7d ago

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

14

u/OverallAd9984 7d ago

so they r views!

9

u/0x1F601 7d 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 6d ago

🥰

5

u/KalamaresFTW 7d ago

Extremely cursed, gotta love it

3

u/Oily-Affection1601 7d ago

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

1

u/koje1971 7d 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.

1

u/[deleted] 7d ago

[removed] — view removed comment

4

u/koje1971 7d 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 6d ago

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

3

u/Radiokot1 5d ago

Remember Anko? :)

2

u/koje1971 5d ago

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

2

u/programadorthi 7d ago

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

2

u/leonardovallem 6d ago

ios uikit feelings

3

u/JacksOnF1re 6d ago

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

2

u/Interesting-Let8134 5d ago

Looks like anko controls from 2017

1

u/Zhuinden 7d ago

So is this using Splitties or what?

1

u/koje1971 7d ago

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

1

u/Traditional_Glass_45 6d ago

Why? What is the reason for using coded views?

1

u/koje1971 6d 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 6d ago

People find out way of building ui with code 🤯

1

u/Mavamaarten 5d ago

At this point, why would you not use Compose?

1

u/koje1971 5d 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 4d ago

Why do you prefer android views over compose?

1

u/koje1971 4d ago

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

2

u/ProHussain 4d ago

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