B4J Question [ABMaterial] get small/med/large screen size

Hilton

Active Member
Licensed User
Longtime User
Hi folks,

Does anyone know how to get what ABMaterial thinks the screen size is(small/med/large). This would be useful for me as it would give me a better idea of what to use as defaults. For example, with a table I would set the default number of lines based on what ABMaterial thinks the screen size is (small/med/large). The user will be able to change the number of lines anyway, but I would like to reduce the number of times the user has to do that. Please note I do not want the actual size, only what ABMaterial thinks the screen is - a small screen or a medium screen or a large screen.

Thank you,
Hilton.
 

alwaysbusy

Expert
Licensed User
Longtime User
Materialize css (the lib ABMaterial is based on) uses this:

Phone portrait: width <=600px
Phone landscape/tablet portrait: width >600px, <=992px
Tablet landscape/desktop: width > 992px

You can also use the ABMPlatform object to check if there is some useful information:

B4X:
Dim info As ABMPlatform = page.GetPlatform

The result is something like this:

Manufacturer:
Layout :
Name : Chrome
Version: 47.0.2526.106
OSArchitecture: 64
OSFamily: Windows
OSVersion: 10
Prerelease:
Product:
Description: Chrome 47.0.2526.106 32-bit on Windows 10 64-bit
User Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36

The height is a different story.

In the ABMFeedback app I experimented with the number of table rows a little bit to try to archieve what you want to do (with mixed results):

B4X:
 ' in the Private Sub WebSocket_Connected (WebSocket1 As WebSocket)
    Dim NowWH As String = ABM.GetBrowserWidthHeight(page) ' returns a string "width;height"
    If NowWH <> "" And NowWH <> ";" Then ' check if we got something useful back
        Dim split() As String = Regex.Split(";", NowWH) ' split the string
        Dim NewH As Int = split(1) - 350 ' minus the height of the header and the footer
        NewH = NewH / 50  ' one row in the table about 50 pixels   
        NewH = NewH / 5 ' to normaize it /5 *5
        NewH = NewH * 5
        If NewH >= 10 Then ' should show a minimum of 10 rows
            MaxRows = NewH
        End If
    End If
    Log(MaxRows)

The problem is this does not work if the user zoomed in his browser.
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
Hi folks,

Does anyone know how to get what ABMaterial thinks the screen size is(small/med/large). This would be useful for me as it would give me a better idea of what to use as defaults. For example, with a table I would set the default number of lines based on what ABMaterial thinks the screen size is (small/med/large). The user will be able to change the number of lines anyway, but I would like to reduce the number of times the user has to do that. Please note I do not want the actual size, only what ABMaterial thinks the screen is - a small screen or a medium screen or a large screen.

Thank you,
Hilton.

https://www.b4x.com/android/forum/threads/abmaterial-number-of-data-grid-rows-to-display.61701/

I write the number of rows the user selects to a table so it stays fixed for his screen... assuming he/she uses the same screen all the time.
 
Upvote 0
Top