I’m developing an application that should display all the images you have in external storage. It’s an app just for a researching work not as a final product.
The problem I have is that the app shows me a few images until I have an Out of Memory error.
There is a way to deal with images efficiently? or avoid that error?
I post here my main-page.xml
<Page xmlns="http://www.nativescript.org/tns.xsd" loaded="onPageLoaded">
<ListView id="listview" items="{{ myItems }}">
<ListView.itemTemplate>
<StackLayout orientation="horizontal">
<Image src="{{ src }}" class="imagebox" stretch="none" />
</StackLayout>
</ListView.itemTemplate>
</ListView>
</Page>
I have an array where I put each image path.
Yep, one of the many frustrations for developers of native apps (specifically on Android handling memory with images). Luckily the NativeScript team has packaged Fresco (a Facebook library for memory management) https://github.com/NativeScript/nativescript-fresco
and a community member has packaged Picasso (Square library) here : https://github.com/triniwiz/nativescript-image-cache-it
Using one of those libraries should resolve any issues with memory management/images on Android.
Also there is a plugin nativescript-image-caching which uses Glide library on Android and the standard DSWebImage on iOS.
https://market.nativescript.org/plugins/nativescript-image-caching
Related
I have built a UWP app through unity using the UWP build settings and I would like to incorporate WinUI controls into the app. I have installed the required packages through Nuget, but the WinUI controls do not appear in the XAML designer. However, once I build and run the app, the WinUI controls are displayed. This is honestly not that much of a problem since at the moment the app is simple and I dont mind building each time to check the controls, but I have plans to expand the app and at that point I fear that the development pace would be hampered.
To test the problem, I have built a separate app through visual studio to make sure that it works, and indeed there are no problems and all the WinUI controls appear on this app. I have also made sure that I have the same version of the Microsoft.XAML.UI pacakge and that the target platforms and all other settings are identical.
I have attached an image below of me trying to add a colorpicker control to the project but it is not showing up in the XAML designer.
Image of xaml designer not displaying controls
I would like to also note that I get an error on my xaml stating:
Type Microsoft.UI.Xaml.Controls.ColorPicker cannot be created in XAML. Building the project may help
And here is the xaml code:
<Page
x:Class="Croissant.MainPage"
IsTabStop="false"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Croissant"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d"
Background="#FFFFFF">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<SwapChainPanel Grid.Row="0" x:Name="m_DXSwapChainPanel">
<Grid x:Name="m_ExtendedSplashGrid" Background="#FFFFFF">
<Image x:Name="m_ExtendedSplashImage" Source="Assets/SplashScreen.png" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Grid>
</SwapChainPanel>
<muxc:ColorPicker Grid.Row="1"/>
</Grid>
Thank you so much in advance for your help and advice!
I want to display some .gif icons on android project.. but many icons not moving.. I don't know why.. ?
I have a <Image/> with propertie: IsAnimationPlaying="True" and this work only for three gifs and other gifs not moved...
<Image Source="rain.gif"
IsAnimationPlaying="True"
WidthRequest="40"
HeightRequest="40"
Grid.Row="2"
Grid.Column="1"/>
In drawable folder I set all gifs to AndroidResource property but this not work..
Аnd after all, the icon is not the one I placed in drawable folder.
I set rain.gif who is not this one from the screenshot.
This is real icon rain.gif:
So the first three .gif icons is moved and worked (thermometers), other .gif icons not worked and rain.gif is different I don't know why ?
Could it be that the problem is that I have the same name with different extensions in drawable folder, like: rain.jpg rain.png...
I try many times to clear the project and build again and again but not worked for me..
Becasue Android doesn't have built-in support for loading gif into ImageViews.
You could display gif with some commonly used third-party controls.
Like FFImageLoading
<ffimageloading:SvgCachedImage Source="rain.gif" WidthRequest="40"
HeightRequest="40"
Grid.Row="2"
Grid.Column="1"/>
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 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>