Android Question Separate layouts for different orientations ?

Discussion in 'Android Questions' started by severika, Apr 29, 2015.

  1. severika

    severika Member Licensed User

    Hello,

    I am trying make a GUI which looks nice on both orientations.

    I created a layout "welcome_v" for vertical orientation and a layout "welcome_h" for horizontal.

    I am switching between the two when I detect an orientation change, such as in Resume and Create methods, as following :

    If Activity.Width > Activity.Height Then
    Activity.LoadLayout("welcome_h")
    Else
    Activity.LoadLayout("welcome_v")
    End If

    It works fine so far.

    I this a good practice ? Can you please recommend a better one ?
    Thank you.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    No. You should instead use a single layout file with two variants. This way you will only need to modify the views position and size.

    With that said, in many cases you can use a single variant and change the layout with anchors and designer script.
     
    lemonisdead, Peter Simpson and NJDude like this.
  3. Peter Simpson

    Peter Simpson Expert Licensed User

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