I'm using this awesome tutorial for xamarin forms in order to get multiple images from gallery on android devices: https://www.xamboy.com/2019/03/12/select-multiple-images-and-videos-in-xamarin-forms/
Everything is working fine. I wonder if there's a way, on code implementation for Android, to intercept when user click on each image.
Right now there is just method for OnActivityResult. Any idea?
Maybe use something like that:
<Image>
<Image.GestureRecognizers>
<TapGestureRecognizer NumberOfTapsRequired="1" Tapped="MyMethodThatFiresWhenImageIsTapped"/>
</Image.GestureRecognizers>
</Image>
Related
The code below when entered in AppShell for Xamarin Forms only works in Android. In iOS the Switch is rendered but can't be toggled (as if it is disabled). Are there any tricks to making this work in iOS as well or is this a bug?
I tried placing the the Switch in a completely different ContentView and loading it in the Shell with local: and also tried including the Switch in the DataTemplate directly. All of them work in Android, just not iOS.
Thanks for your help
<MenuItem>
<Shell.MenuItemTemplate>
<DataTemplate>
<ContentView>
<Switch IsToggled="True" />
</ContentView>
</DataTemplate>
</Shell.MenuItemTemplate>
</MenuItem>
I have some icons on my xamarin forms project. I need a circle background for my icon. See the screenshot below:
I tried Xam.Plugins.Forms.ImageCircle plugin and tried Framelayout. Imagecircle plugin only cropping the icon and Framelayout gives a rounded corner layout. Nothing gives me a perfect circle background. I go through the FFImageloading documentation, but which is also the same as Imagecircle plugin.
Image code
<Image
Source="ic_group_fill_xx.png"
WidthRequest="25"
HeightRequest="25"/>
Is there any way to achieve this feature?
I usually prefer to make an icon that by default has a circle in it, doesn't make sense to add extra code for something that can be done for free.
There is great document by Android on working with Images for Android applications which can be found here, you can also use Android Asset Studio for creating awesome images.
I normally use an ImageButton for this (and because of the clicked property you don't need to use Gesture Recognizers for detecting taps)
The code below gives me a perfect circle on Android & iOS
<ImageButton Source="icon_name"
BackgroundColor="Blue"
HeightRequest="60"
WidthRequest="60"
CornerRadius="30"
Padding="15"
Clicked="Btn_Clicked" />
The image below is from my app, the image button is inside AbsoluteLayout and the icon is 64x64
Use the ImageCircle.Forms.Plugn plugin which I am already using it,
Import namespace like below,
xmlns:controls="clr-namespace:ImageCircle.Forms.Plugin.Abstractions;assembly=ImageCircle.Forms.Plugin"
And use the image control like below sample,
<controls:CircleImage
Source="{Binding ProfileImage}"
HorizontalOptions="Start"
VerticalOptions="Center"
WidthRequest="40"
Aspect="AspectFill"
BorderColor="#B8BCC9"
BorderThickness="1"
HeightRequest="40" />
I am very new to Xamarin. I need to add a image button that display Facebook icon on my Xamarin app and when the user clicks on that icon, I need to be redirected to http://www.facebook.com. How can I accomplish this. Here is what I have so far
<StackLayout Padding="50">
<Image Source="facebook.png" HeightRequest="80" WidthRequest="80" >
<Button Text="Mission" Clicked="Mission_Clicked"></Button>
<Button Text="Continue" Clicked="Continue_Clicked"></Button>
</StackLayout>
On the click of Facebook, I just want the Facebook page to be displayed on the phones.
Any help will be appreciated.
Button already has an Image property
<Button Clicked="FacebookClicked" Image="facebook.png" HeightRequest="80" WidthRequest="80" />
UPDATE Xamarin.Forms 3.4.0
ImageButton:
The ImageButton view combines the Button view and Image view to create a button whose content is an image.
<ImageButton Source="xamagon.png"
BackgroundColor="Transparent"
WidthRequest="300"
HeightRequest="300"
FlexLayout.AlignSelf="Center"
FlexLayout.Grow="1"
Clicked="ImageButton_Clicked"
Aspect="AspectFit">
</ImageButton>
Try to place an image instead of button.
You can make use of Tap Gesture Gesture Recognizer to take click events.
Try something like this :
I have several images with the png extension in my project where in android and ios they appear correct, already in universal windows they do not appear. I made the test the following I changed one of the images to jpg and funcionol, appeared my image in universal windows. Will I have to change all the images? Or do you have a way to solve this so that my images will be PNG?
An example of how I call the pictures ...
<StackLayout Orientation="Horizontal">
<Image Source="facebook.png" HeightRequest="25" WidthRequest="25"/>
<Image Source="twitter.png" HeightRequest="25" WidthRequest="25"/>
<Image Source="whatsapp.png" HeightRequest="25" WidthRequest="25"/>
</StackLayout>
Most likely URI resolution fails, you should really follow documentation's guidelines when it comes to working with embedded images.
i have added reference of Xlabs.Forms to my project for circleimage.but it not shape image to round.Please help for how to Implement. My Code is:
xmlns:controls="clr-namespace:XLabs.Forms.Controls;assembly=XLabs.Forms"
<controls:CircleImage Aspect="AspectFill"
HeightRequest="30"
HorizontalOptions="Fill"
Source="Images/05.png"
WidthRequest="40" />
But it gives rectangle image on ios,Windows Phone Device.
The Xlabs Project have become very monolithic and is not that actively maintained these days (I feel so).
If your only requirement for adding XLabs is for Round Image button then I suggest you not to use the XLabs one due to the following reasons :
It increases the size of the apk or ipa significantly.
There might be some compatibility issues with other 3rd party controls you use.
My suggestion is to use the following plugin - Circle Image Control Plugin for Xamarin.Forms created by James Montemagno.
Links :
Nuget
Git Hub
Usage : In your iOS, Android, and Windows projects call:
Xamarin.Forms.Init(); //platform specific init
ImageCircleRenderer.Init();
XAML :
<controls:CircleImage Source="{Binding Image}" Aspect="AspectFill">
<controls:CircleImage.WidthRequest>
<OnPlatform x:TypeArguments="x:Double"
iOS="55"
Android="55"
WinPhone="75"/>
</controls:CircleImage.WidthRequest>
<controls:CircleImage.HeightRequest>
<OnPlatform x:TypeArguments="x:Double"
iOS="55"
Android="55"
WinPhone="75"/>
</controls:CircleImage.HeightRequest>
</controls:CircleImage>