Device layout values

barx

Well-Known Member
Licensed User
Longtime User
Does anyone know of a fairly comprehensive list of layout values (width (px), height (px), densities, etc)?

The reason I ask is I'm trying to create a different layout for my app on larger screen widths (tablets in landscape).

I had my app running along nicely on my phone, nearly finished just inputting data into database as and when I get time. I kind of knew it wouldn't play nice on a tablet but didn't know for sure until I got one for my B'day. Anyways, what I would like to do is create a layout similar to the gmail app on tablets in landscape. i.e. thin menu on left, main page on right. I should be able to set the layout no problem. The problem I'm having is thinking of the parameters to define this large wide screen. I currently have :

B4X:
Dim DeviceValues As LayoutValues: DeviceValues = GetDeviceLayoutValues
   Dim DeviceDensity As Float: DeviceDensity = Density
   
   Log("Device Values = " & DeviceValues)
   Log("Device Density = " & DeviceDensity)
   
   If DeviceValues.Width >= 800 AND DeviceDensity = 1 Then
      Constant.DeviceType = "Tablet"
      Constant.DeviceOrientation = 0
   Else
      Constant.DeviceType = "Phone"
      Constant.DeviceOrientation = 1
   End If
   
   Dim Device As Phone
   Device.SetScreenOrientation(Constant.DeviceOrientation)

As you can see from the code I want to lock the orientation based on device. So, if it has this big wide screen, lock orientation to landscape and use the gmail'ish layout. Otherwise, lock portrait and use the original layout.

My current parameters are min 800px wide and a 1 density though I'm sure there will be devices out there that will be missed with this. I don't imagine for one minute that all tabs a density=1. Should I set this to <=1.5?

Any tips much appreciated Thanks

This is for this app btw. If anybody looked at it before they will know the standard layout.

http://www.b4x.com/forum/basic4android-updates-questions/15136-required-permissions.html#post85848
 

barx

Well-Known Member
Licensed User
Longtime User
Î actually went a little off track with that. The idea of a list was so I could look at what devices used what values to determine the best parameters to use. Wasn't wanting someone else to do my donkey work. ;)
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
Ah yes the designer. I got so stuck doing layout in code I forgot to check out the designer lol. I take to use variants like it does in the designer. One must use the designer. I.e. you can't define the variant in code?

Thanks again.

Sent from my HTC Vision using Tapatalk
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
O to look at it another way, can you create a layout in the designer for say a 7" Tablet (Landscape). But if the app isn't run on this variant, drop back to what I already have in code?
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
That is what I was trying to achieve in the first place Erel though I explained it very badly. I think you probably right though. Create another variant and then have separate activities too as now I think about it they will be very different. I'm sure I've read that you can check if a certain layout/variant is being used or was I dreaming? lol.

I guess I could add a view only to the tablet and the check if such view has been initialized. I would need to know So I can lock the orientation. Cheers
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
OK, so I now have 2 variants. I'm using 2 panels to split the views up. 1 has views common to both variants the other holds views that I only want showing on the larger screens. on the smaller screen variant this panel is simply off screen.

Then using the following code I check the position of the second panel (this is how I am determining which variant is in use)
B4X:
   If pnlContent.Top = 0 Then
         Constant.DeviceType = "Tablet"
         Constant.DeviceOrientation = 0
         
      Else
         Constant.DeviceType = "Phone"
         Constant.DeviceOrientation = 1
      End If
Constant.DeviceType is used to choose which activity to load from here. ones for large screens or small screens.

Would this be classed as a decent way to go about it or can anyone suggest an altenative.

Cheers. I will post some screens of the achieved and it may clear things up for my poor explanaintions.

thanks
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
Screens as promised:

On Phone:
User makes selections through menus.
Phone_Menu.jpg

And then the details are shown based on menu selections
Phone_Detail.jpg

On Tablet:
Menu Items on left with a 'Hint' on right.
Tablet_Menu.jpg

Details show on right pane once selections made on menu.
Tablet_Detail.jpg

Very happy with the turnout so far. Still need a little tweaking but the majority of it is now there.

Thanks all envolved.
 
Upvote 0
Top