Android Question How to align things within a TabPage?

Discussion in 'Android Questions' started by FERNANDO SILVEIRA, Apr 11, 2018.

  1. FERNANDO SILVEIRA

    FERNANDO SILVEIRA Active Member Licensed User

    I had a single layout named "Play" with 4 buttons that I dinamically positioned the fields within it and it seemed visually perfect. Then I decided to use TabHosts and add an extra "About" layout.

    Now the original buttons that used to be aligned based on activity.Width seems a little displaced to the right of the screen. Also, a button that used to be anchored to the botton, now is hidden.

    What should I consider in terms of screen size when using TabHost?

    Regards,
    Fernando

    Code:
    Sub Activity_Create(FirstTime As Boolean)
        
    'Do not forget to load the layout file created with the visual designer. For example:
        Activity.LoadLayout("Main")
        tbnPages.AddTab(
    "Play","Play")
        tbnPages.AddTab(
    "About","About")
        tbnPages.Height = 
    Activity.Height
        tbnPages.Width = 
    Activity.Width
          
        
    Dim wGap As Int = (tbnPages.Width - (2 * lblYellow.Width)) / 3
        lblYellow.left = wGap
        lblYellow.Top = wGap
        lblGreen.left = lblYellow.Width + (
    2 * wGap)
        lblGreen.Top = lblYellow.top
        lblRed.left = lblYellow.Left
        lblRed.Top = lblYellow.height + (
    2 * wGap)
        lblBlue.left = lblGreen.left
        lblBlue.Top = lblRed.top
    End Sub
     
  2. Eme Fibonacci

    Eme Fibonacci Well-Known Member Licensed User

    You can export a sample project as zip. This helps understand the issue and find a solution.
    File>Export as Zip
     
  3. FERNANDO SILVEIRA

    FERNANDO SILVEIRA Active Member Licensed User

    Hi, Eme

    Find attached the .zip file.

    Thanx for your attention.

    Fernando
     

    Attached Files:

  4. klaus

    klaus Expert Licensed User

    You should use DesignerScripts in the Designer as suggested by Erel in the other thread.
    Instead of adjusting the views in the code, add code below in the DesignerScripts of the Play layout.
    Code:
    wGap = (100%x - (2 * lblYellow.Width)) / 3
    lblYellow.left = wGap
    lblYellow.Top = wGap
    lblGreen.left = lblYellow.Width + (
    2 * wGap)
    lblGreen.Top = lblYellow.top
    lblRed.left = lblYellow.Left
    lblRed.Top = lblYellow.height + (
    2 * wGap)
    lblBlue.left = lblGreen.left
    lblBlue.Top = lblRed.top
    When you load a layout onto a Panel, 100%x is equal to Panel.Width and 100%y is equal to Panel.Height, and the anchors work !
     
    Last edited: Apr 16, 2018
    Erel and FERNANDO SILVEIRA like this.
  5. FERNANDO SILVEIRA

    FERNANDO SILVEIRA Active Member Licensed User

    Got you.

    Thanx.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice