Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all 204402 articles
Browse latest View live

Slow performance inside ListView with images

$
0
0

I have a problem, I am using inside my listview images from Url, every time I scroll a list it is laging soo much. I am using default images from xamarin forms:

 <RelativeLayout>
                        <Frame
                            Margin="{Binding PictureMargin}"
                            Padding="0"
                            CornerRadius="{Binding CornerRadius}"
                            HasShadow="False"
                            HeightRequest="{Binding Size}"
                            IsClippedToBounds="True"
                            IsVisible="{Binding IsProfilePicture}"
                            WidthRequest="{Binding Size}">
                            <Image Aspect="AspectFill" Source="{Binding ProfilePicture}" />
                        </Frame>
                        <Frame
                            Margin="{Binding PictureMargin}"
                            Padding="0"
                            BackgroundColor="#4074DD"
                            CornerRadius="{Binding CornerRadius}"
                            HeightRequest="{Binding Size}"
                            HorizontalOptions="Center"
                            IsVisible="{Binding IsInitials}"
                            VerticalOptions="FillAndExpand"
                            WidthRequest="{Binding Size}">
                            <Label
                                FontSize="{Binding TextSize}"
                                HorizontalOptions="Center"
                                Text="{Binding Initials}"
                                TextColor="White"
                                VerticalOptions="Center" />
                        </Frame>
                        <Frame
                            Margin="{Binding CompanyPictureMargin}"
                            Padding="0"
                            BackgroundColor="Transparent"
                            CornerRadius="{Binding CompanyCornerRadius}"
                            HasShadow="False"
                            HeightRequest="{Binding CompanyPictureSize}"
                            HorizontalOptions="Center"
                            IsClippedToBounds="True"
                            IsVisible="{Binding IsCompanyPicture}"
                            WidthRequest="{Binding CompanyPictureSize}">
                            <Image Source="{Binding CompanyPicture}" />
                        </Frame>
                        <Frame
                            Margin="{Binding PictureMargin}"
                            Padding="0"
                            BackgroundColor="#aaaaaa"
                            CornerRadius="{Binding CornerRadius}"
                            HeightRequest="{Binding Size}"
                            HorizontalOptions="Center"
                            IsVisible="{Binding IsExtraCounter}"
                            VerticalOptions="FillAndExpand"
                            WidthRequest="{Binding Size}">
                            <Label
                                FontSize="{Binding TextSize}"
                                HorizontalOptions="Center"
                                Text="{Binding ExtraCountText}"
                                TextColor="White"
                                VerticalOptions="Center" />
                        </Frame>
                    </RelativeLayout>

I am using this view inside my listView

<ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <Frame
                                Margin="20,10"
                                Padding="2"
                                BackgroundColor="White"
                                CornerRadius="12"
                                HasShadow="False"
                                HeightRequest="130">
                                <Grid
                                    Margin="10"
                                    ColumnSpacing="0"
                                    RowSpacing="8">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>
                                    <Frame
                                        Grid.Row="0"
                                        Grid.Column="0"
                                        Margin="0,0,10,0"
                                        Padding="0"
                                        BackgroundColor="{Binding StatusOfMeetingColor}"
                                        CornerRadius="5"
                                        HasShadow="False"
                                        HeightRequest="10"
                                        VerticalOptions="Center"
                                        WidthRequest="10" />
                                    <Label
                                        Grid.Row="0"
                                        Grid.Column="1"
                                        Grid.ColumnSpan="2"
                                        Margin="0"
                                        FontAttributes="Bold"
                                        FontSize="18"
                                        LineBreakMode="TailTruncation"
                                        Text="{Binding CreatorDisplayName}"
                                        TextColor="Black"
                                        VerticalOptions="Center" />
                                    <customViews:UsersPictures
                                        Grid.Row="0"
                                        Grid.Column="3"
                                        Margin="0"
                                        Padding="0"
                                        UserList="{Binding UserPicturesItems}" />

I know that the images make this problem, because when I comment them performance of the list is much better. What is more this images flicker. Anyone have this problem ?


App deploys to iOS simulator but not to iPad Pro

$
0
0

I've got an App that I would like to test on my iPad Pro 12.9" (first generation, iOS 13.5.1). I am able to deploy it to a simulator but when I try to deploy it to my device Visual Studio 2019 Pro on Windows gives an error when building (not deploy):

Severity Code Description Project File Line Suppression State
Error Error while loading assemblies: /Users/paulsinnema/Library/Caches/Xamarin/mtbs/builds/eTabber.iOS/576cbcad2fb4a8344d3b1823e4c08bc2/bin/iPhone/Debug/git2-106a5f2.dll eTabber.iOS C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets 844

The path /Users/paulsinnema/Library/Xamarin/ exists but there no mtbs inside it.

Using: iPad connected via network (not cable, because the Mac Mini I'm using is in the Attic).

iOS Build
SDK Version: Automatic
Linker behavior: Link All
Supported Architecture: ARM64
HttpClient implementation: Managed (default)
Use LVVM optimizing compiler: false
Enable the Mono interpreter: true
Perform all32-bit float operations as 64-bit float: true
Strip native debugging symbols: true
Enable incremental builds: false
Use the concurrent garbage collector: true
Enable device-specific builds: false

iOS Bundle signing
Scheme: Automatic Provisioning

Build
Platform target: x64
Output path: bin\iPhone\Debug\

How to pass initialization argument to view in MVVM

$
0
0

I have a view with two of viewmodels, one of the viewmodels takes a constructor argument. The correct MVVM method is to do as much as possible in the xaml form so have a ResourceDictionary, which accepts the required argument when the view model is instantiated. It works fine if I set a static value manually, for testing, but the argument needs to be passed dynamically and I can find no documentation that explains how to do this.

Here is my xaml for the viewmodels and the argument:

<ContentPage.Resources>
    <ResourceDictionary>
        <local:JobViewModel x:Key="jobViewModel" >
            <x:Arguments>
                <x:String x:Key="arg"></x:String>
            </x:Arguments>
        </local:JobViewModel> 
        <local:StatusViewModel x:Key="statusViewModel" />
    </ResourceDictionary>
</ContentPage.Resources>

The main view passes the argument to the new view:

    public JobPage(string jobId)
    {
        InitializeComponent();
}

but I can't even see a way to pass the argument. i.e. Resources["arg"] = jobId before InitializeComponent can not work and it is to late to pass it after InitializeComponent. How is an argument passed to the view to use during initialization, where the viewmodel can take it as a contructor argument?

How to implement backgrounding & local notifications in Xamarin.Forms iOS application ?

$
0
0

I am creating Xamarin.forms application. I want my application to hit a REST API after every 1 minute, get json data from there and show notification if new data is received. I want this to work on iOS platform.
Can anyone please guide me ?
I am new to iOS.

My Xamarin app crash after 5 secedes

$
0
0

06-07 19:01:32.416 I/ame.shobiklobi(14434): Explicit concurrent copying GC freed 3(16KB) AllocSpace objects, 0(0B) LOS objects, 75% free, 1988KB/8132KB, paused 39us total 11.546ms
06-07 19:01:32.417 D/Mono (14434): GC_TAR_BRIDGE bridges 32 objects 32 opaque 0 colors 32 colors-bridged 32 colors-visible 32 xref 0 cache-hit 0 cache-semihit 0 cache-miss 0 setup 0.07ms tarjan 0.01ms scc-setup 0.01ms gather-xref 0.00ms xref-setup 0.00ms cleanup 0.03ms
06-07 19:01:32.417 D/Mono (14434): GC_BRIDGE: Complete, was running for 12.37ms
06-07 19:01:32.417 D/Mono (14434): GC_MAJOR_CONCURRENT_FINISH: (finishing) time 323.55ms, stw 113.13ms los size: 2048K in use: 1036K
06-07 19:01:32.417 D/Mono (14434): GC_MAJOR_SWEEP: major size: 102400K in use: 92364K

The video / music should be rotated as rotated phone

$
0
0

How to Detect the phone is rotate in run time(like TextChanged Event). When the phone orientation change Portrait to Landscape is Any Function can Use.

Can not start Android emulators?

$
0
0

Failed to open /usr/local/google/home/joshuaduong/emu/master/prebuilts/android-e
mulator-build/qemu-android-deps/windows_msvc-x86_64/qemu.conf, err: 2
Windows Hypervisor Platform accelerator is operational
emulator: ERROR: It seems too many emulator instances are running on this machin
e. Aborting.

Where do I add AndroidManifestPlaceholders build variables?

$
0
0

I'm trying to create a bindings library from a proprietary SDK (as an .aar) but an integration step is to define a custom build variable in build.gradle.
Because Xamarin doesn't use gradle, how do i go about this step so that the android manifest is populated with my custom build value rather than ${foo}?
It currently throws the error:
Tag <receiver> attribute name has invalid character '{'. (APT0000)

I've looked at the AssemblyInfo properties as well as adding directly to the csproj file:
<AndroidManifestPlaceholders> <foo>FOOBAR</foo> </AndroidManifestPlaceholders>

It looks like the GenerateJavaStubs file does have a property for ManifestPlaceholders but I don't know how to access that.
I want to avoid having to change the reference in the SDK (and avoid those meetings to request permission).

Is there a way to add a custom build variable to a bindings library?

Thanks!


No teams in dropdown for auto provisioning

$
0
0

Hi all - Old timer from the MonoTouch days trying to catch up. I decided to buy myself a license of Apple Developer (instead of going the free provisioning route). Nevertheless, I cannot follow the automatic provisioning tutorial since there are no teams in the dropdown. I do have a Team ID when I go in my Apple Developer account on Apple website. Where do I go from here?

Need to integrate a Webinar like GoToWebinar into Xamarin Android

$
0
0

I need to create a an application which can live stream a webinar from the GoToWebinar into my application. Is there any sdk for android or .Net that we can use. Any help will be appreciated.

ON/OFF of GPS reception

$
0
0

As shown in the code below, when you press (Start) (GPSStart_Clicked) or end (GPSStop_Clicked), you may not receive, or the reception may not end.

private void GPSStart_Clicked(Object sender, EventArgs e)
{
    _ = StartListening();
}

private void GPSStop_Clicked(Object sender, EventArgs e)
{
    _ = StopListening();
}

public async Task StartListening()
{
    if (CrossGeolocator.Current.IsListening)
        return;
    await CrossGeolocator.Current.StartListeningAsync(TimeSpan.FromSeconds(1000), 1, false);
    CrossGeolocator.Current.PositionChanged += PositionChanged;

}

public async Task StopListening()
{
    if (!CrossGeolocator.Current.IsListening)
        return;
    await CrossGeolocator.Current.StopListeningAsync();
    CrossGeolocator.Current.PositionChanged -= PositionChanged;
}

private void PositionChanged(object sender, PositionEventArgs e)
{
    ~~~~~~~~~~~~~~~~~~~~
}

CollectionView included additional space at the bottom

$
0
0

Hi Team,

I am using the CollectionView with Xamarin.Forms (4.1.0.483098-pre1) package. Facing an issue "Extra spacing was added at the bottom of the colletionview when the row-height is set to 'Auto' in its parent grid".

Below is the code I use

    <ContentPage.Content>
        <ScrollView BackgroundColor="Brown">
            <Grid BackgroundColor="Red" RowSpacing="0" Padding="0" ColumnSpacing="0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="*"></RowDefinition>
                </Grid.RowDefinitions>

                <CollectionView ItemsSource="{Binding Categories}" Grid.Row="0" BackgroundColor="MistyRose">
                    <CollectionView.ItemsLayout>
                        <GridItemsLayout Span="2" Orientation="Vertical"></GridItemsLayout>
                    </CollectionView.ItemsLayout>
                    <CollectionView.ItemTemplate>
                        <DataTemplate>  
                            <StackLayout Orientation="Vertical" BackgroundColor="Yellow" Padding="12">
                                <Image Source="{Binding ImagePath}" Aspect="Fill" WidthRequest="160" HeightRequest="150"></Image>
                                <Label Text="{Binding ImageName}" FontSize="14" FontAttributes="None" TextColor="Black"></Label>
                            </StackLayout>
                        </DataTemplate>
                    </CollectionView.ItemTemplate>
                </CollectionView>

                <Label Text="Home" TextColor="Blue" Grid.Row="1" VerticalOptions="Start" VerticalTextAlignment="Start" BackgroundColor="Green"></Label>

            </Grid>
        </ScrollView>
    </ContentPage.Content>

The grid clearly has 2 rows and there is a space added between the rows without specifying any properties for that spacing. I haven't checked in UWP and iOS. I cannot post the screenshots because of the restriction "You have to be around for a little while longer before you can post links."

Implement Android background task with dependency service

$
0
0

Hello all, I am implementing the Android version of the following iOS code. I am wondering how I can implement the same functionality in Android? Do I need to create a job scheduler/service in another class first before implementing code here?

Thanks!

            var task = UIApplication.SharedApplication.BeginBackgroundTask(() => { });
            Task.Run(async () => {
                await // do something;
                UIApplication.SharedApplication.EndBackgroundTask(task);
            });

Shell hide back button

$
0
0

HI, How to completely hide a back button in Xamarin.Forms shell?
BackButtonBehavior IsEnabled="False" -does nothing on IOS
IconOverride="" -hides it but someplace in the toolbar it is still reserved for it. and it looks like a workaround not a solution.

AppShell Searchhandler Questions

$
0
0

I need to submit search paramaters to REST service.

  • Question 1: Is it appropriate to call a REST service from the SearchHandler class?
  • Question 2: Is it possible to display an ActivityIndictor while waiting for results of the REST call?
  • Question 3: I have tried, without success, to only display the search results upon confirmation -- via "OnQueryConfirmed" -- but the behavior is not what I expected. The results don't display on initial confirmation, BUT on subsequent expansion of the SearchHandler and after pressing another key they do show -- but not filtered based on the current text enterred.
  • Question 4: Other than the MS documentation I have not found any examples of implementations of SearchHandler on the web, including StackOverflow. Is Searchhandler ready for prime time?

Thanks in advance.
-- Dean


Scrolling multiple lists at the same time.

$
0
0

That is roughly the problem I have.
Here is the code:

<CollectionView x:Name="colview" VerticalScrollBarVisibility="Never" HorizontalScrollBarVisibility="Never" RemainingItemsThreshold="5">
                <CollectionView.ItemsLayout>
                    <GridItemsLayout Orientation="Horizontal"/>
                </CollectionView.ItemsLayout>
                <CollectionView.ItemTemplate>
                    <DataTemplate>
                        <Grid >
                            <Grid.RowDefinitions>
                                <RowDefinition Height="160"/> <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="120"/>
                            </Grid.ColumnDefinitions>
                            <Label Text="{Binding name}" BackgroundColor="{Binding backcol}" FontSize="20" FontAttributes="Bold" WidthRequest="100" Margin="0,0,0,2"
                                   HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"
                                   HorizontalTextAlignment="Center" VerticalTextAlignment="Center"
                                   Grid.Column="0" Grid.Row="0"/>
                            <ListView ItemsSource="{Binding listtimes}" HasUnevenRows="False" SelectionMode="None" SeparatorVisibility="None" 
                                      VerticalScrollBarVisibility="Never" HorizontalScrollBarVisibility="Never"
                                      CachingStrategy="RecycleElementAndDataTemplate" Scrolled="ListView_Scrolled"
                                      Grid.Column="0" Grid.Row="1" >
                                <ListView.ItemTemplate>
                                    <DataTemplate>
                                        <ViewCell>
                                            <Label Text="{Binding time, StringFormat='{}{0:H\\:mm}'}" BackgroundColor="{Binding backgr}" FontSize="15" WidthRequest="100"
                                                   HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"
                                                   HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/>
                                        </ViewCell>
                                    </DataTemplate>
                                </ListView.ItemTemplate>
                            </ListView>
                        </Grid>
                    </DataTemplate>
                </CollectionView.ItemTemplate>
            </CollectionView>

Yep, t's a CollectionView loaded by bindings. To make it short, we give it a collection of objects (let's call them "points", if you will) with 3 properties: "name" (string) "listtimes" (list) and "backcol" (another string). We then bind the property "name" to a label and "listtimes" to a ListView (this is where things get confusing). "listtimes" is another list of objects (call 'em "times") with their own variables: "time" (DateTime) and "backgr" (string). Both "backcol" and "backgr" are Hex codes for the background color of each label.

In the CS part of the code we do this:

List<point> points = new List<point>([all data goes here]);
colview.ItemsSource = points;

and the rest is binding...

As you can see, the ListViews have a "Scrolled" property, but we are unable to access the other lists in order to, when one is scrolled, scroll the rest equally. I know this sound ridiculous but, hey, I can't contradict my higher-ups! That's what they want and that's what I'm asking.

Thank you very much and apologies for this mess.

Best regards.

P.S.: Some of the ListViews may not have the same amount of lines. In fact a handful of them might have so few items that cannot scroll. Sooo yeah...

Splash screen with background image and app version text

$
0
0

I'm developing an app with splash screen. At the beginning the splash screen only had a background image. I added a style in Resources/values/styles.xml file:

<style name="Theme.Splash" parent="android:Theme">
  <item name="android:windowBackground">@drawable/splash_screen_image</item>
  <item name="android:windowNoTitle">true</item>
  <item name="android:windowFullscreen">true</item>
  <item name="colorPrimaryDark">#313131</item>
</style>

And I used it as SplashActivity's theme, (and I set the activity as main launcher):

[Activity(Label = "MY APP", Theme = "@style/Theme.Splash", MainLauncher = true, NoHistory = true,
    Icon = "@mipmap/ic_launcher", RoundIcon = "@mipmap/ic_round_launcher", ScreenOrientation = ScreenOrientation.Portrait)]
public class SplashActivity : Activity
{
    protected override void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);
        this.StartActivity(typeof(MainActivity));
    }
}

It worked fine, it showed the image at startup. Now I want to add the app version to the splash screen. I created SplashScreen.axml layout file with an image and a label with "hardcoded" version number on the bottom left corner:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="#000000"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:src="@drawable/splash_screen_image"
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:scaleType="centerCrop"
        android:padding="0dp"
        android:adjustViewBounds="true" />
    <TextView
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="V0.6"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textColor="#FFFFFF"
        android:id="@+id/version_text_view"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_marginLeft="5dp"
        android:layout_marginBottom="5dp"/>

</RelativeLayout>

And added this content view in SplashActivity:

[Activity(Label = "MY APP", Theme = "@style/Theme.Splash", MainLauncher = true, NoHistory = true,
    Icon = "@mipmap/ic_launcher", RoundIcon = "@mipmap/ic_round_launcher", ScreenOrientation = ScreenOrientation.Portrait)]
public class SplashActivity : Activity
{
    protected override void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);
        SetContentView(Resource.Layout.SplashScreen);
        this.StartActivity(typeof(MainActivity));
    }
}

In this case nothing happens, the Theme.Splash is displayed. Then I changed OnCreate method to start MainActivity using a timer:

[Activity(Label = "Cocina Tiflotécnica", Theme = "@style/Theme.Splash", MainLauncher = true, NoHistory = true,
    Icon = "@mipmap/ic_launcher", RoundIcon = "@mipmap/ic_round_launcher", ScreenOrientation = ScreenOrientation.Portrait)]
public class SplashActivity : Activity
{
    protected override void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);
        SetContentView(Resource.Layout.SplashScreen);

        Timer timer = new Timer();
        timer.Interval = 10; // 10 millis.
        timer.AutoReset = false; // Do not reset the timer after it's elapsed
        timer.Elapsed += (object sender, ElapsedEventArgs e) =>
        {
            this.StartActivity(typeof(MainActivity));
        };
        timer.Start();
    }
}

In this case Theme.Splash is displayed first (a few seconds) and then Resource.Layout.SplashScreen layout with version number (a few seconds too). The background image is fit in different way in the theme and the layout, so the background changing is very noticeable.

Is there an elegant way to show a background with a text in the splash screen?

Adjusting controls for different resolutions

$
0
0

If the resolution is different, not all controls may be displayed.
Is there a way to adjust the controls automatically?

Adding items in a favorite layout

$
0
0

hello everyone, please help me, i am creating an android xamarin application, i have several layouts with textViews and checkbox (see image) but i want to create a favorite layout to add the elements of the other layouts by clicking on the checkbox, thank you in advance for your help

Xamarin.Android, AndroidManifest.xml, AndroidManifestMerger, xmlns:tools schema, replace always manu

$
0
0

When compile my Xamarin Forms Android application, visual studio, show me an error's list of AndroidManifest.xml conflict, for example:

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(3,3): Error AMM0000:  is also present at AndroidManifest.xml:14:9-41 value=(@string/app_name). (AMM0000)

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(3,3): Error AMM0000:  Suggestion: add 'tools:replace="android:label"' to <application> element at AndroidManifest.xml:19:3-79:17 to override. (AMM0000)

So i open AndroidManifest.xml from debug folder, replace with tools:replace into application tag, add tools schema into manifest tag, save it, recompile my application and it run without error.

But WHENEVER i compile my Xamarin Forms Android application, must follow previous steps MANUALLY.

I also add manifestmerger.jar, into my Android .csproj

This issue is showed into DEBUG and RELEASE mode!!

Environment

  • Visual Studio Community 2019 for Mac Version 8.6.4
  • Xamarin Forms = 4.7.0.968
  • Xamarin.Android = Versione: 10.3.1.4
Viewing all 204402 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>