FFImageLoading CachedImage is not showing gif image - xamarin.forms

I am using xamarin forms for my app development. I am using FFimageloading for view gif file. I am using the following code in xaml file:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="myproject.View.MasterDetailPage1Detail"
Icon="UEmlogotiny.png"
xmlns:ff="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms"
xmlns:ffSvg="clr-namespace:FFImageLoading.Svg.Forms;assembly=FFImageLoading.Svg.Forms"
xmlns:ffTransformations="clr-namespace:FFImageLoading.Transformations;assembly=FFImageLoading.Transformations"
>
....
<ff:CachedImage x:Name="Gif" Source="resource://UETrack.Beats.App.loader.gif" VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand"
WidthRequest="75" HeightRequest="75"
DownsampleToViewSize="True" IsVisible="True"/>
Change the Image Build Action to "Embedded Resource"
The gif image has showed on Orio. But not show in below Oreo.
Can anyone help me to resolve this issue.

Where did you add your image? To the Drawable folders? xxhdpi, etc?
If so,you can simple do:
Source="loader.gif"

Related

mvvmcross xamarin.forms PictureChooser

I am trying to develop a photo app using the PictureChooser plugin. I see that the sample uses Xamarin.iOS. I've googled for examples where the plugin uses Xamarin.Forms but can't find any. I understand how binding works for labels, text editors, and buttons; however, the binding btw the page's image control and the viewmodel's byte[] has got me stomped.
DAA.UI project:
In CameraPage.XAML:
<Image x:Name="MyImage"
Source="{Binding Bytes, Converter={StaticResource InMemoryImage}}"
Aspect="Fill"
HeightRequest="{OnPlatform iOS=300, Android=250}"
WidthRequest="{OnPlatform iOS=300, Android=250}"
HorizontalOptions="Center" />
In App.XAML:
<?xml version="1.0" encoding="utf-8" ?>
<Application
x:Class="DamageAssessmentApp.UI.App"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="clr-namespace:MvvmCross.Forms;assembly=MvvmCross.Forms"
xmlns:resources="clr-namespace:DAA.UI.Resources"
xmlns:local="using:DAA.UI"
xmlns:nativeValueConverters="using:DAA.UI.NativeValueConverters">
<Application.Resources>
<!-- Application resource dictionary -->
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<resources:Colors />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
<nativeValueConverters:NativeInMemoryImageValueConverter x:Key="InMemoryImage"/>
</Application.Resources>
</Application>
Value Converter file:
using MvvmCross.Forms.Converters;
namespace DAA.UI.NativeValueConverters
{
public class NativeInMemoryImageValueConverter : MvxNativeValueConverter<MvxInMemoryImageValueConverter>
{
}
}
The compiler can't find MvxInMemoryImageValueConverter in the value converter file.
If you are using MVVMCross you should find an example that works with Xamarin.Forms, in which case a good place to start it's their Github.
Or you have to implement it in each platform and use a DependencyService to get the implementation
Other Alternatives
Xamarin Community Toolkit
Another alternative for a camera App is Xamarin Community Toolkit Camera View. In that same link there is an example. But there are more examples in their Github. This is fully compatible with Xamarin.Forms and brings a little more control over the CameraView
Xamarin.Essentials
Xamarin.Essentials offers the MediaPicker that let's the user upload a photo from the gallery or take a new one. But the action of the photo in handled by the OS, so for you it's like a black box. You call the function, and get the photo.

Xamarin Forms Flyout Page not showing in iOS

I'm using xamarin forms flyout page to make the settings page, it works fine like the image below but it does not show in iOS. This setting page is not the root page
Android:
iOs:
My flyout page is just a normal flyout out page was created from visual studio.
Flyout page:
app shell:
I don't know what happened, anyone has any idea?
It is not recommend to use FlyoutPage inside shell, you can post an issue in github if you insist. However, you can use TabbedPage and FlyoutPage together instead.
like:
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:My_Forms_Test2.Views"
x:Class="My_Forms_Test2.MainTabbedPage">
<NavigationPage Title="Settings" >
<x:Arguments>
<local:Page1/>
</x:Arguments>
</NavigationPage>
<local:Page2/>
<local:Page3/>
flyoutpage:
<FlyoutPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:My_Forms_Test2.Views"
x:Class="My_Forms_Test2.Views.Page1"
Title="Settings">
<FlyoutPage.Flyout>
<local:MenuPage/>
</FlyoutPage.Flyout>
<FlyoutPage.Detail>
<local:Page2/>
</FlyoutPage.Detail>
</FlyoutPage>
Here is the result:

Create custom toolbar for ios in xamarin visual studio 17

I want to create a custom toolbar with app name and his icon this toolbar should be included in all Page of the applications. This toolbar should be for ios because in all others examples which i haave seen they are using Main.storyboard which iss not in visual studio 17. Thanks
I want to create a custom toolbar with app name and his icon this toolbar
You can refer to this official document to know more about ToolBarItem in Xamarin Forms.
Code as follow in Xaml:
<ContentPage.ToolbarItems>
<ToolbarItem Name="MenuItem1" Icon="icon.png" Priority="0" Order="Primary" />
</ContentPage.ToolbarItems>
Or in ContentPage :
new ToolbarItem () { Icon = "icon.png" }
And this app name can be setted in ContentPage with Title property as follow:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:App3"
xmlns:autocomplete="clr-namespace:Syncfusion.SfAutoComplete.XForms;assembly=Syncfusion.SfAutoComplete.XForms"
x:Class="App3.MainPage"
Title="AppNameTitle">
Here is a good article for reference.

Xamarin navigation bar has unwanted default icon, impossible to alter or remove

Recently I upgraded my Xamarin project to all the latest DLLs. Now on the navigation bar an icon has appeared on Android (haven't looked at iOS yet). See generic icon:
After spending hours searching and prototyping code I still can't figure out how to change or get rid of the icon! Doing a recursive search for png files in my project finds no such image.
There is a method SetTitleIcon but that method doesn't do anything. Some people talk about a toolbar xaml file in the layout folder, but I have no such file.
I followed this tutorial: https://xamarinhelp.com/xamarin-forms-toolbar/ but can only add icons, it doesn't remove the default icon.
I found this demo project: https://developer.xamarin.com/samples/monodroid/Supportv7/AppCompat/Toolbar but that code is quite different from mine. Do I need to go that route?
Anyway, my main xaml file:
<?xml version="1.0" encoding="utf-8" ?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:SharedMobile"
NavigationPage.HasNavigationBar="true"
x:Class="SharedMobile.MainPage">
<MasterDetailPage.Master>
<local:MainPageMaster x:Name="MasterPage" />
</MasterDetailPage.Master>
<MasterDetailPage.Detail>
<NavigationPage BarBackgroundColor="#DCDCDC">
<x:Arguments>
<local:ActionProcessesPage />
</x:Arguments>
</NavigationPage>
</MasterDetailPage.Detail>
</MasterDetailPage>
There is little to no mention anywhere else in the project of a navigation bar. I did try to add a NavigationPage.Icon under the Navigation Page. Nothing happened.
I only do Xamarin part-time is my excuse.
One of the main reasons I post on Stack Overflow is often (for some reason) shortly after posting I will figure out or find the answer.
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:SharedMobile;assembly=MyApp.Mobile"
NavigationPage.TitleIcon="transparent.png"
x:Class="SharedMobile.ActionProcessesPage">
In MainActivity.cs (in the Android project),
protected override void OnCreate(Bundle bundle)
{
...
ActionBar.SetIcon(null);
LoadApplication(new Forms.App());
}
Source

Display png image xamarin.ios

I have a Xamarin.ios project running on Visual Studio for Imac.
I would like to display a png image file using XAML and C#. Would it be best to use a dependency service to construct the image object in C#?
code snippet:
<StackLayout Orientation="Horizontal">
<Image Name="MyImage" Width="180" />
</StackLayout>
I placed my png file in the assets.xcassents folder. The file name is picture.png. How would I get this code to display in the xaml? What would the
code look like. Thanks for your input.
In your case you can use the property Source of the Image tag in XAML. Than you are able to use the following code snippet:
<StackLayout Orientation="Horizontal">
<Image x:Name="MyImage" Source="picture.png" WidthRequest="180" />
</StackLayout>
And there was another issue in your XAML snippet, because the property Width is a readonly property for internal use by Xamarin.Forms. So if you want to specify the width of the image you must use the WidthRequest property.
Got the code working! Changed to BundleResouces and do not copy for the property on the image file. Also move image File to a separate folder.

Resources