B4J Question Pane.Prefwidth will not refresh position inner views

MarcRB

Active Member
Licensed User
Longtime User
Hello,

I played with some panels (pane) and created a layout with a left and right pane.
The right pane can be made smaller by editing PrefWidth. The left pane will scale to fit the space.
But the inner content of that pane is not be repositioned, unless all views are anchored.

For me, it is difficult to explain. Please try the attached example.

What do I have to do in order to refresh the positions?
And why it restores to original size after resize?


pane resize:
#REGION ToggleMenu
Private Sub btnToggleRightPane_Click
    'width 190 / 50
    If PanMenu.Prefwidth <> 50 Then
        PanMenuClose
    Else
        PanMenuOpen
    End If
End Sub

Sub PanMenuOpen()
    PanMenuSize(190,4,2)
    btnToggleRightPane.Text = Chr(0xF061)
End Sub

Sub PanMenuClose()
    PanMenuSize(50,4,2)
    btnToggleRightPane.text = Chr(0xF060)
End Sub

Sub PanMenuSize(intSize As Int,intGap As Int, intMarge)
    PanMenu.prefWidth = intSize
    PanLayouts.Left = intMarge
    PanLayouts.PrefWidth = B4XPages.GetNativeParent(Me).Width    - (intMarge  + intGap + intSize + intMarge)
    PanMenu.left = PanLayouts.Left + PanLayouts.PrefWidth + intGap
End Sub
#End Region
 

Attachments

  • TestPaneResize.zip
    3.5 KB · Views: 70
Solution
PrefWidth is really ugly... Switch to B4XView.

For the resizing to work automatically you need to move all views inside PanLayouts to a separate layout file and load it with PanLayouts.LoadLayout.
Top