B4A Library Before-after image slider library

This is a Beta version of before-after image comparison slider written completely in b4a.
Attached are the .jar and .xml files to be placed in additional libraries folder of b4a.
No extra jar files needed.

How to use:
1- Place a beforeAfterImgSlider in designer, give a name or leave default
2- Generate as a member with methods ( 'dragged' and 'ImagesSet' if needed)
2- Initialize two bitmaps ( before and after ) from two images as:
B4X:
Dim beforeBmp as Bitmap
beforeBmp.Initialize(File.DirAssets, "beforeImg.jpg")
Dim afterBmp as Bitmap
afterBmp.Initialize(File.DirAssets, "afterImg.jpg")
2- set Images:
beforeAfterImgSlider1.setImages(beforeBmp, afterBmp)
3- run

Methods , properties and events:
Methods:
-Initialize: no parameters
-SetImages: 2 parameters (beforeBMP , afterBMP)
Properties:
-ShowThumb: whether to show the thumb to drag the line between the two images (can be set in designer or at runtime).
-ThumbColor: the color of the thumb (can be set in designer or at runtime).
Events:
BeforeAfterImgSlider_Dragged (clipPosition as int): show how much of the before image is shown.
BeforeAfterImgSlider_ImagesSet: just to check if the two images are loaded (True or False).

1737803616658.png

Here is a Demo:
A demo example is attached.
A watermark (JK) is overlying the customview at time being.
Source code will be gladly presented on donation of $30. It took a lot of time to develop.

Edit: Example added.
 

Attachments

  • jk_imgCompare.jar
    4.1 KB · Views: 8
  • jk_imgCompare.xml
    3.2 KB · Views: 6
  • jkcompareEx.zip
    9.3 KB · Views: 5
Last edited:

jkhazraji

Active Member
Licensed User
Longtime User
You could have saved yourself the time if you had searched in the forum:
But it didn't take longer than 1 hour back then, there were good code snippets in the forum.
So what. A lot of code can be searched and found in this forum and everyone is free to display his/her merchandise. I did not know of code inspector around.
However, is that a promotion for your code in my post?
 
Top