B4A Library [B4X][XUI] ExpandView - source code

Attached the version 2.0 (not compatible with the 1.0) - b4a code module and library (see post #6). This version allows to also collapse a B4XView.


Premise: I wanted to create an animation; it did not work the first time and then, from the wrong code, I wrote these few lines, nothing special (for this reason I do not charge € 100 :p).

Very minimal code module / library.

This code uses my other code module / library, ViewPos; you could mix the two modules or replace the two methods used here in ExpandView:

ViewPos.GetBottom(Vw)
to
Vw.Top + Vw.Height - 1

and

ViewPos.GetRight(Vw)
to
Vw.Left + Vw.Width - 1


Note that jxExpandView and xExpandView libraries already "contains" ViewPos, you don't need to add it to your projects.

Example:
ExpandView.Expand(400, ImageView1, ExpandView.EXPVW_LEFT_TO_RIGHT)


Expand.gif


applied to a xCustomListView:
Expand xCLV.gif
 

Attachments

  • ExpandView.bas
    1.1 KB · Views: 131
  • xExpandView lib.zip
    4.9 KB · Views: 124
  • jxExpandView lib.zip
    2.5 KB · Views: 120
  • ExpandView 2 lib.zip
    5.9 KB · Views: 124
  • ExpandView 2 module.zip
    1.4 KB · Views: 129
Last edited:

LucaMs

Expert
Licensed User
Perfect; I just realized that the "same code" in b4j does not shows the same animation (animations start from the corners of the view).



Works SetLayoutAnimated differently in the two platforms?
No, SetLayoutAnimated works in the same way on all platforms (b4a, b4j and, I guess, also b4i).
Erel :eek::) pointed out to me the problem that is only in the sample project:
The problem with the animation happens because the PreserveRatio property of the ImageView is set to True. So the image is scaled automatically. Set it to False and it should work.

Then the module will work well with b4j too.
 
Last edited:

LucaMs

Expert
Licensed User
It would be more useful if you could also collapse a b4xView... but:

1) I had no intention of developing stuff like this :p
2) the best thing here is that you do not have to deal with the size of the view; if instead you want also to collapse it, you must store its size.

Well, if someone wants also the possibility to collapse the view and they will ask for this, maybe I will add this feature.
 

LucaMs

Expert
Licensed User
New version, with collapse; currently it is imperfect because of a small bug in SetLayoutAnimated (soon fixed by Aniwhere Software, I am sure :)).

The minimum width of the first panel is set to 10dip, so you can touch it to open.

1.gif


Very simple code:
B4X:
Sub Activity_Create(FirstTime As Boolean)
'...
    ExpandView.Init
    ExpandView.AddView(Panel1, 2dip, 0, -1, ExpandView.EXPVW_DIR_BOTTOM_TO_TOP)
    ExpandView.AddView(Panel2, 2dip, 10dip, -1, ExpandView.EXPVW_DIR_LEFT_TO_RIGHT)
End Sub


Sub chkEpanded_CheckedChange(Checked As Boolean)
   ExpandView.Animate(Panel1, -1)
End Sub

Sub Panel2_Click
   ExpandView.Animate(Panel2, -1)
End Sub
 
Last edited:
Top