• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Create main menu layout like Robo Defense

gilangb89

Newbie
First of all, I'm sorry if this is in the wrong section.

Hi, I'm new to android. I am used to code in C#, and I'm also developing an application for Windows Phone 7. I found out that creating a simple layout in android took a lot more of effort comparing to Windows Phone 7.

I'm going to create this main menu layout that looks similar to Robo Defense's main menu (the menu where you choose to start game, view achievement, etc).

note: I already put the
android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
to the AndroidManifest.xml.

Check the picture below:

nwx2ef.png


It was easy to create that kind of main menu in Windows Phone 7, but I had difficulties in Android when trying to design it from the main.xml file.

I was thinking of using a LinearLayout, and then put a TextView inside the LinearLayout. And after that, I put a TableLayout for the buttons under the TextView. What bugs me is that the table didn't show up, only the text view was displayed.

Then I changed to using LinearLayout again but then put a TableLayout, then put the TextView inside the TableLayout (into a TableRow), hoping that it would be centered inside the table above the buttons. The result is like this:

2nbsj6h.png


The "Title Bar" isn't centered inside the table, and the table layout creates a tablerow with two elements, one of which is empty, and the rows below it change their widths to fit the rows above them.

So that's it, i'm stuck here. What should I do? Any help is appreciated, thank you :)
 
You should handle the drawing and the touch events yourself. Make your app check if a touch event is within a bounding box of an item.
 
thank you, the touch events is not a problem (yet) since those are just buttons, and buttons can be clicked (or touched) without any problems :)

but that's not what i'm asking for now, i'm curious how to make that kind of layout not how to interact with touch events

thanks!
 
I'm guessing you used "fill_parent" in some places where you wanted "wrap_content".

fill_parent will stretch something, wrap_content will not.
 
Add "android:layout_span=2" to your TextView's XML definition. Right now, the TextView just occupies one column of the table row; the layout_span attribute will make the TextView span both columns.
 
Back
Top Bottom