A code module (also compiled as library), compatible with B4A, B4J and B4I, with few methods about views' position.
As you know, in b4a we have:
but we don't have:
which is available in the Designer (script).
Many times, surely you have written code like the following:
and even more complicated code than this.
With this "library" you can write:
which is simpler and also more readable, I think.
FUNCTIONS:
- GetBottom(Vw As B4XView) As Int
Returns the bottom position of Vw.
- GetRight(Vw As B4XView) As Int
Returns the right position of Vw.
- GetLocation(Vw As B4XView) As tLocation
Returns the absolute position of Vw on screen.
METHODS:
- SetRight(Vw As B4XView, Right As Int)
- SetRightAnim(Duration As Int, Vw As B4XView, Right As Int)
Sets the right position of Vw.
- SetBottom(Vw As B4XView, Bottom As Int)
- SetBottomAnim(Duration As Int, Vw As B4XView, Bottom As Int)
Sets the bottom position of Vw.
- SetRelRight(ViewToMove As B4XView, RelativeView As B4XView, HorDistance As Int)
- SetRelRightAnim(Duration As Int, ViewToMove As B4XView, RelativeView As B4XView, HorDistance As Int)
Sets the right position of ViewToMove on left of RelativeView, spaced of HorDistance.
- SetRelBottom(ViewToMove As B4XView, RelativeView As B4XView, VertDistance As Int)
- SetRelBottomAnim(Duration As Int, ViewToMove As B4XView, RelativeView As B4XView, VertDistance As Int)
Sets the bottom position of ViewToMove on top of RelativeView, spaced of VertDistance.
- VerCenterBetween(ViewToPlace As B4XView, TopView As B4XView, BottomView As B4XView)
- VerCenterBetweenAnim(Duration As Int, ViewToPlace As B4XView, TopView As B4XView, BottomView As B4XView)
Centers vertically ViewToPlace between TopView and BottomView.
- HorCenterBetween(ViewToPlace As B4XView, LeftView As B4XView, RightView As B4XView)
- HorCenterBetweenAnim(Duration As Int, ViewToPlace As B4XView, LeftView As B4XView, RightView As B4XView)
Centers horizontally ViewToPlace between LeftView and RightView.
As you know, in b4a we have:
B4X:
SomeView.Left
but we don't have:
B4X:
SomeView.Right
Many times, surely you have written code like the following:
B4X:
View1.Left = View2.Left + View2.Width - View1.Width
With this "library" you can write:
B4X:
ViewPos.SetRight(View1, ViewPos.GetRight(View2))
FUNCTIONS:
- GetBottom(Vw As B4XView) As Int
Returns the bottom position of Vw.
- GetRight(Vw As B4XView) As Int
Returns the right position of Vw.
- GetLocation(Vw As B4XView) As tLocation
Returns the absolute position of Vw on screen.
METHODS:
- SetRight(Vw As B4XView, Right As Int)
- SetRightAnim(Duration As Int, Vw As B4XView, Right As Int)
Sets the right position of Vw.
- SetBottom(Vw As B4XView, Bottom As Int)
- SetBottomAnim(Duration As Int, Vw As B4XView, Bottom As Int)
Sets the bottom position of Vw.
- SetRelRight(ViewToMove As B4XView, RelativeView As B4XView, HorDistance As Int)
- SetRelRightAnim(Duration As Int, ViewToMove As B4XView, RelativeView As B4XView, HorDistance As Int)
Sets the right position of ViewToMove on left of RelativeView, spaced of HorDistance.
- SetRelBottom(ViewToMove As B4XView, RelativeView As B4XView, VertDistance As Int)
- SetRelBottomAnim(Duration As Int, ViewToMove As B4XView, RelativeView As B4XView, VertDistance As Int)
Sets the bottom position of ViewToMove on top of RelativeView, spaced of VertDistance.
- VerCenterBetween(ViewToPlace As B4XView, TopView As B4XView, BottomView As B4XView)
- VerCenterBetweenAnim(Duration As Int, ViewToPlace As B4XView, TopView As B4XView, BottomView As B4XView)
Centers vertically ViewToPlace between TopView and BottomView.
- HorCenterBetween(ViewToPlace As B4XView, LeftView As B4XView, RightView As B4XView)
- HorCenterBetweenAnim(Duration As Int, ViewToPlace As B4XView, LeftView As B4XView, RightView As B4XView)
Centers horizontally ViewToPlace between LeftView and RightView.
Attachments
Last edited: