Android Question TabStripViewPager - Can it display 2 tabs on a wider screen

73Challenger

Active Member
Licensed User
Any way to have the tab strip display 2 tabs at the same time on a wider screen device...for example when opening a Galaxy ZFold3?

For example, if my tab strip has 2 tabs, TabA and TabB. On normal, narrow aspect devices, I'd like to display TabA (only). But on a wide screen I'd like to see both TabA and TabB side by side.

I'm guessing I'll have to add a new combined form and tab strip to load after checking the screen width, but I wanted to ask y'all first to try to avoid having duplicated forms and code. Thanks much!
 

Lucas Siqueira

Active Member
Licensed User
Longtime User
check the inches...

if it's less than 6 you load a designer, if it's bigger load another designer
B4X:
If GetDeviceLayoutValues.ApproximateScreenSize < 6 Then
    'phones
    Root.LoadLayout("layout_small")
Else
    'tablets
    Root.LoadLayout("layout_large")
End If
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
but I wanted to ask y'all first to try to avoid having duplicated forms and code
You do not need two layouts. One is enough.
B4X:
For Each lbl As Label In GetAllTabLabels(TabStrip1)
        Dim lv As LayoutValues = GetDeviceLayoutValues
        If lv.ApproximateScreenSize > 6 Then
            lbl.Width = 50%x
        Else
            lbl.Width = 100%x
        End If
    Next
B4X:
Public Sub GetAllTabLabels (tabstrip As TabStrip) As List 
    Dim jo As JavaObject = tabstrip
    Dim r As Reflector
    r.Target = jo.GetField("tabStrip")
    Dim tc As Panel = r.GetField("tabsContainer")
    Dim res As List
    res.Initialize
    For Each v As View In tc
        If v Is Label Then res.Add(v)
    Next
    Return res
End Sub
 
Upvote 1
Cookies are required to use this site. You must accept them to continue using the site. Learn more…