abstract designer and emulator rotation

jermitts

Member
Licensed User
Longtime User
Is there weirdness involved when rotating an emulator that is connected to the abstract designer when layout is set to match connected device?

Just thought I'd ask before I take the time to explain what's happening, because I'm sure I'm just doing something wrong that is obvious and every newbie has done.

I searched for previous threads, but didn't see anything applicable. I'm still working my way through the Beginners Guide V1.6.

Thanks,

Jeremy
 

jermitts

Member
Licensed User
Longtime User
maybe it's an emulator issue?

I had an app working in both modes (portrait and landscape) and now it's not rotating right. I don't know what I changed that broke it!

When the app loads, everything draws right no matter which orientation the emulator is set to. When I switch with ctrl+f11 it does one of two things:

If I start the app in landscape and switch to portrait, everything re-arranges perfectly. When I switch back to landscape, the buttons don't redraw and the text on them is sideways.

If I start the app in portrait and switch to landscape, the buttons don't redraw correctly and the text on them is sideways. (they do redraw- it flashes black and they come back?)

I guess this is the relevant code. My emulator is sized to a kindle fire, 600x1024 @ 160dpi (they are 169 but I guess I'm supposed to use 160?)

B4X:
Sub Activity_Create (FirstTime As Boolean)
   'globals: 
   'Dim Buttons(18) As Button
   'Dim materials(15) as string
   'materials(0)="Concrete"
   'materials(1)="Sand"
   'materials(2)="Asphalt"
   ' ...

   Activity.LoadLayout("18buttons.bal")
   Buttons = Array As Button (Button01,Button02,Button03,Button04,Button05,Button06,Button07,Button08,Button09,Button10,Button11,Button12,Button13,Button14,Button15,Button16,Button17,Button18)

   Dim i,t,l As Int
   t=10
   l=10
   If Activity.Height>Activity.Width Then
      'portrait
      Panel1.Top = 45
      Panel1.Left = 10
      Panel1.Width = 480
      Panel1.Height = 955
      For i = 0 To 17
         Buttons(i).Top = t
         Buttons(i).Left = l
         Buttons(i).Width = 150
         Buttons(i).Height = 150
         Buttons(i).Text = materials(i)
         l=l+155
         If ((i+1) Mod 3) = 0 Then 
            t=t+155
            l=10
         End If
      Next
   Else
      'landscape
      Panel1.Top = 100
      Panel1.Left = 35
      Panel1.Width = 955
      Panel1.Height = 480
      
      For i = 0 To 17
         Buttons(i).Top = t
         Buttons(i).Left = l
         Buttons(i).Width = 150
         Buttons(i).Height = 150
         Buttons(i).Text = materials(i)
         l=l+155
         If ((i+1) Mod 6) = 0 Then 
            t=t+155
            l=10
         End If
      Next
   End If
   
   Button17.Visible = False
   Button18.Visible = False
end sub
 
Upvote 0

Kevin

Well-Known Member
Licensed User
Longtime User
Before you drive yourself crazy like I did.....

Are you using Android 2.3.x (API 9 or 10) for the AVD? There is a bug in it where the device will get stuck in a certain orientation and shows stuff sideways. You can temporarily fix it by going to the home screen in the AVD, but it will happen again eventually.

If you are just wanting to see how it looks on that device configuration (dimensions / density) just create a new AVD with the same specs but instead use a different API level (such as 7 or 8).

Issue 13189 - android - Orientation does not change from landscape to portrait on Emulator on 2.3 - Android - An Open Handset Alliance Project - Google Project Hosting


Hope this helps!
 
Upvote 0

jermitts

Member
Licensed User
Longtime User
yup

Okay, that was it. I was, indeed, driving myself crazy.

I guess I'll hook up the device and start using it instead of the emulator!

Thanks so much!!!

Jeremy
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…