Here is a library which lets you show and play gif-animations in your apps.
This library is using android.graphics.Movie.
It is implemented as a CustomView which you add in the B4A designer.
You can also pause and resume the playback of the gif-animation as if it was a mediaplayer. This might be useful for some of you.
If you need to create gif-animations on your device, you could use my B4A ffmpegencoder library.
It is very simple to use. Here below is some sample-code.
B4AGifViewer
Version: 1
Please remember that creating libraries and maintaining them takes time and so does supporting them. Please consider a donation if you use my free libraries as this will surely help keeping me motivated. Thank you!
This library is using android.graphics.Movie.
It is implemented as a CustomView which you add in the B4A designer.
You can also pause and resume the playback of the gif-animation as if it was a mediaplayer. This might be useful for some of you.
If you need to create gif-animations on your device, you could use my B4A ffmpegencoder library.
It is very simple to use. Here below is some sample-code.
B4X:
#Region Project Attributes
#ApplicationLabel: B4AGifViewer
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private GifPlayer1 As GifPlayer
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("1")
GifPlayer1.SetGifPath("/storage/sdcard/gif4.gif")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
B4AGifViewer
Version: 1
- GifPlayer
Fields:- ba As BA
- AddToParent (Parent As ViewGroup, left As Int, top As Int, width As Int, height As Int)
- BringToFront
- DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
- Initialize (EventName As String)
- Invalidate
- Invalidate2 (arg0 As Rect)
- Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
- IsInitialized As Boolean
- IsPaused As Boolean
- IsPlaying As Boolean
- Pause
- Play
- RemoveView
- RequestFocus As Boolean
- SendToBack
- SetBackgroundImage (arg0 As Bitmap)
- SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
- SetGifPath (path As String)
- SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
- SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
- SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
- Background As Drawable
- Color As Int [write only]
- Enabled As Boolean
- Height As Int
- Left As Int
- Padding()() As Int
- Parent As Object [read only]
- Tag As Object
- Top As Int
- Visible As Boolean
- Width As Int
Please remember that creating libraries and maintaining them takes time and so does supporting them. Please consider a donation if you use my free libraries as this will surely help keeping me motivated. Thank you!
Attachments
Last edited: