This is B4XPages example for LOTTIE implementation on Android and iOS
B4A Implementation
Uses AXrLottie. Download the library and dependencies here: https://www.b4x.com/android/forum/threads/axrlottie.126248/
1. Libraries to Add:
AxrLottie
Appcompat
2. Add this to MAIN
And this
3. Add Appcompat Theme in Manifest
4. Declare your Lottie and LottieView and Initialise
5. Initialise the lottieview and add it to Root or any panel you like and Display
NOTE: Make sure to copy the lottie files (json) to Directory internal before you can use. It does not work form DirAssets
B4A Implementation
Uses AXrLottie. Download the library and dependencies here: https://www.b4x.com/android/forum/threads/axrlottie.126248/
1. Libraries to Add:
AxrLottie
Appcompat
2. Add this to MAIN
B4X:
#Extends : androidx.appcompat.app.AppCompatActivity
And this
B4X:
#If java
static {
// load native rlottie library
System.loadLibrary("jlottie");
}
#End If
3. Add Appcompat Theme in Manifest
B4X:
SetApplicationAttribute(android:theme,"@style/AppTheme")
CreateResource(values,styles.xml,
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#3F51B5</item>
<item name="colorPrimaryDark">#303F9F</item>
<item name="colorAccent">#FF4081</item>
</style>
</resources>)
4. Declare your Lottie and LottieView and Initialise
B4X:
Dim AXrLottie As AXrLottie
Dim LottieView As AXrLottieImageView
5. Initialise the lottieview and add it to Root or any panel you like and Display
B4X:
LottieView.Initialize("")
pnlLottie.AddView(LottieView,0,0,pnlLottie.Width,pnlLottie.Height)
Dim Drawable As AXrLottieDrawableBuilder
Drawable.InitializeFromFile(File.DirInternal,"emoji_simple.json") _
.SetAutoRepeat(Drawable.AUTO_REPEAT_INFINITE) _
.SetAutoStart(True) _
.SetCacheEnabled(False)
LottieView.SetLottieDrawable(Drawable.Build)
NOTE: Make sure to copy the lottie files (json) to Directory internal before you can use. It does not work form DirAssets
Attachments
Last edited: