B4A Library [Class] ExpandViews

A class / library to easily manage the expansion / collapsing of N B4XViews.


The initial code was here:

Due to some problems with the SetLayoutAnimated command, it was not possible to get good animation for Collapse; it is then necessary to use the @Informatix's library NineOldAndroids, so the class posted here only works with b4a-Android. Despite this, I still used the B4XViews.


  • ExpandViews demo.zip
    42 KB · Views: 217
  • ExpandViews lib.zip
    4.8 KB · Views: 207
  • ExpandViews class.zip
    1.3 KB · Views: 223
Last edited:


B4X founder
Staff member
Licensed User
Longtime User
Cross platform collapse view:
Sub CollapseView (View As B4XView, Duration As Int) As ResumableSub
   Dim InitialWidth As Int = View.Width
   Dim n As Long = DateTime.Now
   Do While DateTime.Now < n + Duration
       Dim progress As Float = (DateTime.Now - n) / Duration
       View.SetLayoutAnimated(0, View.Left, View.Top, (1 - progress) * InitialWidth, View.Height)
   View.Visible = False
   Return True
End Sub



Licensed User
Longtime User

I prefer to create a module and a library from this module, so I do not have to create an object, I can use the library as a Singleton.

Apart from that I have to mix the various parts developed (modules, classes, folders scattered everywhere in my PC :p:()... I do not know where to post the final module-library, now :(.

I will delete all the threads :p

And all this for... nothing; members think that this code is useless :D

But I think it is useful, especially to create pop-up menus without having to store size and status (open-closed).