Android Question Nexus 7 2013 and Layout Sizes all Wrong

TheWind777

Active Member
Licensed User
Longtime User
I'm a newbie and My new App is coming along nicely... however, since the beginning I've been having severe problems with Designer and layout size relative to my Nexus 7 2013.

In the bottom-left it says Device Details 1200 x 1824 scale = 2 (320 dpi).

I create a layout and choose Nexus 7 Portrait, which says 800 x 1280, scale = 1.33 (212 dpi)

If I draw-out any box, such as a ImageView box, (or any other box) onto the Layout, it will be way too wide and way too tall to fit the screen (disappearing off the right and bottom edges of the screen) which makes it very difficult to set-up a layout screen.

When I load that layout into the Activity with an AddView, thus...


Sub Globals
Dim pnlLayoutACIMWB As Panel
End Sub

Sub Activity_Create(FirstTime As Boolean)
pnlLayoutACIMWB.Initialize("")

Activity.AddView(pnlLayoutACIMWB,0,0,100%x,100%y)

pnlLayoutACIMWB.Top=0
pnlLayoutACIMWB.Left=0

pnlLayoutACIMWB.LoadLayout("main")

pnlLayoutACIMWB.Visible=True
End Sub

It is smaller than the screen in the X and Y and doesn't fill the screen.

When I tried setting the pnlLayoutACIMWB.Height=100dip, pnlLayoutACIMWB.Width=100dip, it created a box that looked about 30 pixels square by 30 pixels square

By experiment, when I'm in the designer and I create an ImageView box, for example, and I drag out the height and width so can just see the red bounding box on the Nexus screen, it's 600 wide x 830 tall - then it looks fine in Designer; but when I load the layout into the App it s too small on the screen.

However, if I figure that the template size they are giving me will look good after loading-in to the Nexus... then load IT in, it is BIGGER than the Nexus screen.

Am I loading it into the App wrong?

I have an Options menu with four choices. The choices hide the other three panels, leaving just the chosen panel. That's all working perfectly. The main problem is... when load the layout in using the above method, the image is too small. I will need to have this work on ANY tablet or phone and I can't even get it to work on this one Nexus?

The secret must have to do with the '100dip' value... but that doesn't work (at least in the manner I'm trying to use it). What am I doing wrong?
 

stevel05

Expert
Licensed User
Longtime User
Have you looked at the beginners guide specifically chapter 5. And the part about scaling and autoscaling at the end of the chapter?
 
Upvote 0
Top