1. Download our Official Android App: Forums for Android!

Apps Create main menu layout like Robo Defense

Discussion in 'Android Development' started by gilangb89, Jun 13, 2010.

  1. gilangb89

    gilangb89 Newbie
    Thread Starter
    Rank:
    None
    Points:
    36
    Posts:
    11
    Joined:
    Jun 3, 2010

    Jun 3, 2010
    11
    1
    36
    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:

    [​IMG]

    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:

    [​IMG]

    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 :)
     

    Advertisement

  2. id0001

    id0001 Well-Known Member
    Rank:
    None
    Points:
    38
    Posts:
    142
    Joined:
    Apr 20, 2010

    Apr 20, 2010
    142
    23
    38
    Student.. also software developer
    Netherlands
    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.
     
  3. gilangb89

    gilangb89 Newbie
    Thread Starter
    Rank:
    None
    Points:
    36
    Posts:
    11
    Joined:
    Jun 3, 2010

    Jun 3, 2010
    11
    1
    36
    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!
     
  4. kevin@teslacoilsw

    kevin@teslacoilsw Well-Known Member
    Rank:
    None
    Points:
    68
    Posts:
    183
    Joined:
    Jun 13, 2010

    Jun 13, 2010
    183
    130
    68
    WidgetLocker developer
    Chicago
    I'm guessing you used "fill_parent" in some places where you wanted "wrap_content".

    fill_parent will stretch something, wrap_content will not.
     
  5. dmitriyk

    dmitriyk Member
    Rank:
    None
    Points:
    18
    Posts:
    44
    Joined:
    Apr 17, 2010

    Apr 17, 2010
    44
    10
    18
    Software Developer
    Salt Lake City, UT
    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.
     
    cp1 and gilangb89 like this.
  6. gilangb89

    gilangb89 Newbie
    Thread Starter
    Rank:
    None
    Points:
    36
    Posts:
    11
    Joined:
    Jun 3, 2010

    Jun 3, 2010
    11
    1
    36
    Hey thanks for the replies, especially dmitriyk. I can now get it working :)
     

Share This Page

Loading...