I would just like to know of something is possible as I am very new to Xamarin and I am on a time limit for an assignment. I don't mind some trial and error, but don't want to waste the time if it isn't possible
I want to have an animated gif as an activity indicator (it is a logo).
I have it working in a WebView - is it possible, in Xamarin,Forms to have this appear as an overlay while waiting on long running methods?
For example. if user clicks on a button, the app gets some info from a webservice then displays in a page. While waiting I would like to show the webview (or any other way to show an animagted gif).
So I am not asking for the code, but just if it is posible.
Thanks in advance
I was able to work this out
With the animated(loading) gif running in the WebView page I called a couple of async methods using following
await Task.WhenAll(method1(), method2());
await Navigate.PushAsync(new NextPage(var1, var2));
The laoding gif (which is an animated logo) runs until the tasks are complete then navigates to the next page
Using an ImageView apparently this doesn't look like its possible to playback animated Gif's as can be seen here http://forums.xamarin.com/discussion/17448/animated-gif-in-image-view.
So i very much doubt the ActivityIndicator would, if it could. In the ActivityIndicator I can't see any functionality to change the content of the what is shown when it is busy.
You could always create your own animated image view by creating a custom renderer instead however. It isn't particularly hard to cycle images at pre-determined gaps if you have a list of the images split up.
GIF images can be used in Xamarin forms to show custom activity indicator, since in Xamarin forms it is not possible to show GIF images directly web-view must be used. For android image must be placed inside assets folder and Build Action must be set to AndroidAsset. For iOS image must be placed inside resources and Build Action must be set to BundleResource. AbsoluteLayout can used for placing the image to center, IsBusy property of mvvm helpers nuget can used for controlling the visibility of the activity indicator. Dependency service must used for getting the image path. You can check this https://github.com/LeslieCorrea/Xamarin-Forms-Custom-Activity-Indicator for example.
Xamarin.Forms now supports .GIF, from version 4.4-pre3 and up on iOS, Android and UWP. Before using, first add the .GIF to the platforms projects, or as an embedded resource in the shared project and then use it like a regular image. The API on the Image control has been extended with the IsAnimationPlaying bindable property.
For e.g., loader.gif is added in all platform projects, then below code make it animating.
<Image Source="loader" IsAnimationPlaying="True" WidthRequest="36" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" />
Related
The question says it all. Upon loading a .gif using either SvgCachedImage or CachedImage it immediately starts playing. I however need to be able to start and stop it according to some logic. Unfortunately, the built in Xamarin Image whilst allowing this takes so way too long to load the 1.2mb .gif that it destroys the user experience.
I have looked through all the properties on CachedImage and SvgCachedImage and cannot find any that may relate to this feature.
I have a working example of my issue here. Basically: when I place the LibVLCSharp MediaPlayerElement into MainPage.xaml directly, I'm able to get playback. When I try to create a reusable control by hosting the MediaPlayerElement in a ContentView that I can use in several parts of my application, all I get is a black screen. The only difference appears to be hosting it inside a ContentView.
Ultimately, my goal is to create a single, reusable class that I can use in several parts of my Xamarin application to render video without copying and pasting code. I've found that it's most stable to set the properties I want to set (clearing the Play/Stop, etc. controls) in XAML. So I've gravitated to implementing my reusable component as a ContentView and just referencing it in multiple places.
Does anyone have any idea on why I get a black screen in this example?
See this line: https://github.com/kwende/LibVLCSharpContentView/blob/65fd9c2bf1afc97374a9052c86b9c066934f7b7d/LibVLCSharpContentView/LibVLCSharpContentView/VideoPlayer.xaml.cs#L28
Your MediaPlayer is not a Bindable property/does not raise PropertyChanged, so the VideoView is initialized with a null media player when it loads, and the never changed, even after the start.
I have a Xamarin forms app where I'm using ListViews to display some data, with pull to refresh enabled. When the ListView is pulled and starts the refresh it has its own spinner animation. However, this doesn't display when the page first loads, and so I've wired in a separate ActivityIndicator to indicate loading for just the first time. It's styled different though. I would prefer to use the ActivityIndicator, since it's what's used through the rest of the app, but I haven't found a way to disable the spinner animation on the ListView yet. Is it possible to disable it? Any suggestions would be appreciated, thanks!
There are a few ways I can think of to solve this.
Don't use Pull-to-refresh. Xamarin.Forms has this built in and you can't customize it without using renderers and altering controls. Instead, start your refresh another way (ToolbarItem, etc) and continue using your custom ActivityIndicator.
Customize the existing ListViews UIRefreshControl. You may be able to use a renderer or "Effect" to customize the RefreshControl being used by the native control. This would allow you to style it a little close to what your custom indicator looks like.
Change the color of the spinner. This is my least favorite option. You could workaround this by changing the color of the spinner to match the background so you don't see it.
I'm using Xamarin for Visual Studio, and am getting frustrated trying to do what I would think should be a very simple thing: creating a launch (splash) screen for iOS, that has a single image that is centered on the screen (vertically and horizontally centered).
I'm creating it the recommended way, using a storyboard (other methods, like using an assets catalog, are considered deprecated as of iOS 9). In the storyboard, I have a View Controller, which contains a View, which contains an Image View. In the Properties pane, I've tried messing with the Mode (in Widget tab), and I've tried playing around with contstraints - which I think might be the key, but it is difficult to understand how it all works together.
You need to add the Splash screen in the applications properties (Launch Images). You need to create the image and upload it via that section. I couldn't find anything saying that the use of Asset catalogues are depreciated.
I tried to find an example for content loading animation (to learn how to implement one in my app). But I couldn't find one.
What I want is: There are 4 listboxes in my mainpage and I want to show a loading animation until the listboxes have completed loading their data.
For example,IMDB application has a loading animation like I want. (You can watch it here http://www.youtube.com/watch?v=AV9BoyGm7Fo)
Any ideas on how to create this?
Thanks
Please refer to these links, as they seem to provide the exact solution to coding this standard loading animation:
Creating a Splash Screen with a progress bar for WP7 applications
High Performance ProgressBar for Windows Phone 7