Android Question Panel Basics

Discussion in 'Android Questions' started by Jeff Mahoney, Apr 22, 2015.

  1. Jeff Mahoney

    Jeff Mahoney Member Licensed User

    Ok, Noob here... First post, probably the beginning of many. Still trying to get my bearings. I know how to do searches in the forums. I come from the PowerBasic community. I'm building my first Android App. Hello all.

    One step back. Is there a basic tutorial that describes what I call "controls" or Addview items in the designer?

    I'm looking at Panels. It seems people describe them as stretchable backgrounds that can resize a series of controls. Some also use them for creating tabbed sliding windows. I just need a starter.

    I would like to create two screens that the user can easily navigate back and forth with a slide.

    I'm also spending a lot of time resizing my controls to fit multiple devices. I see the designer scripts section and I seem to have a good handle on it, but my trial and error runs are getting annoying.

    I have an EditText control (Description) and a label control (Desc_BG) that provides a white background to the Description. I want both controls to almost fill the width of the screen. If the screen is portrait I want the height to be larger. Am I doing this right? Any suggestions for improvement would be great. For some reason, the If statement doesn't seem to be working. This code is in the designer scripts section.

    Code:
    Desc_BG.Top = FileName.Bottom+5dip
    Desc_BG.Width=
    100%x-5dip
    Desc_BG.HorizontalCenter = 
    50%x
    Description.Top = FileName.Bottom+
    5dip
    Description.Width=
    100%x-5dip
    Description.HorizontalCenter = 
    50%x
    If activity.width < activity.height Then
        Desc_BG.Height = 
    60
        Description.Height = 
    60
    Else
        Desc_BG.Height = 
    30
        Description.Height = 
    30
    End If
    Jeff
     
  2. NJDude

    NJDude Expert Licensed User

    For starters, your positioning and sizing should be in DIP, so, you better changes these lines:

    From:
    Code:
    Description.Height = 60
    To:
    Code:
    Description.Height = 60dip
     
  3. lemonisdead

    lemonisdead Well-Known Member Licensed User

    Hello Jeff,

    Welcome. Please did you had the time to take a look at Klaus excellent Beginners Guide ?
     
    Last edited: Apr 22, 2015
  4. Jeff Mahoney

    Jeff Mahoney Member Licensed User

    Thanks NJDude, I made those changes.

    Found the beginners guide lemon. Absorbing...

    Back for more informed questions later.
     
  5. MaFu

    MaFu Well-Known Member Licensed User

    For this behaviour you doesn't need a designer script at all.
    If you set the horizontal anchor value of your controls to "BOTH" the controls will stretched to fit the screen regardless of screen size and orientation.
    Additionally create a landscape layout variant for different control heights.
     
  6. Jeff Mahoney

    Jeff Mahoney Member Licensed User

    The beginners guide really doesn't describe panels. For example: What is a panel? Why would I use it?

    Are panels used to define areas around multiple controls for visual purpose? Can a panel be used to scale subsidiary controls automatically without the use of designer scripts? Meaning, when I resize the panel with controls attached, will the controls automatically stretch with the panel? I can see that when I move the panel, the controls move with it, but when I resize the panel some controls don't get resized and some remain off the panel edge.
     
  7. NJDude

    NJDude Expert Licensed User

    In a few words, a Panel is a container that can hold other views, if you need more info you can use the SEARCH feature, if you type PANEL in the search box above you'll get what you're looking for.

    To resize the views contained in the panel you will have to use the Designer Scripts (using Anchors for example)
     
    Last edited: Apr 23, 2015
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