So I'm attempting to implement my first multiplayer game, and I'm working off an example multiplayer chatroom as the basis. The idea is that the user logs into a lobby chatroom, finds someone to play, then either creates a new game or joins an existing game.
The sample app I'm working from uses tabs for navigation, which I haven't used in an app before, but it seems like a nice approach to the UI.
There's just one hitch...I'm having an unholy bitch of a time customizing the tabs, even in seemingly trivial ways.
What's wrong with the default tab parameters? Well, here's a look at the app with the default tabs:
One thing you might notice off the bat is that the tabs are monstrously huge. You could say "Well, they designed them that way for people with fat thumbs." Yes, but default button sizes are nowhere near that big, and they are easily customizable. Not so with tabs. There's just no reason why they need to be that humongous, taking up a quarter of precious screen space. Perhaps if I were designing apps for a race of sasquatches, this might make sense. But I'm not. Okay, some of the users might be sasquatch-like, but I digress.
It took a while, but I figured out how to resize the tabs to non-monstrous dimensions using the following line for each tab:
tabHost.getTabWidget().getChildAt(index).getLayoutParams().height = 40;
Hey, the size looks pretty good now. I load this onto my actual phone and I can very easily navigate between tabs. 40px is plenty tall for a tab. But wait...the background colors are messed up. That should be easy to fix, right? Guess again, dude. If you change the background color programmatically, it overrides the selected and unselected states, so all the tabs are the same color all the time, whether or not they're selected. You can define a custom set of images for selected, unselected, and focused states, but that's a pain in the ass. Why can't I just adjust the background of the unselected state programmatically? Or maybe I can, but I damn sure can't find out how to do that anywhere. Sounds like if I want to change one thing, I have to define a whole set of custom images, which is dumb.
In lieu of that, I thought "Well, the gray stripe on the tabs actually doesn't look half bad, if it weren't offset from the text. It shouldn't be that hard to reorient the text on a tab." Wrong again, dude. You want to align the text on a tab centered vertically? Or aligned at the top of the tab? As far as I can tell, there's no simple way to do this. Why not?
Oh Android...most of the time designing a UI is elegant and easy. In retrospect you make me glad I never worked with tabs before. And now that I am, you're making me want to claw my eyes out.