I put my adcontrol control to my page. While using test unitid and test appid the ads show up. When I type my app ID and normal adunitid anything shows up in emulator. Place where ad should be visible is transparent.
one more q; how can I "pin" my ad to scroll at the bottom of the screen with scrollviewer?
When I type my app ID and normal adunitid anything shows up in emulator
Many ad-providers are able to detect the emulator and turn off the ads. Deploy to a real device to test them.
how can I "pin" my ad to scroll at the bottom of the screen with scrollviewer?
Just change the layout of your page and put the adcontrol outside of the scrollviewer. For instance:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="80" />
</Grid.RowDefinitions>
<ScrollViewer Grid.Row="0">
<!-- Whatever -->
</ScrollViewer>
<AdControl Grid.Row="1" AdUnit="..." />
</Grid>
To find out what is the problem with the Ad control, register to the AdControlError event and look at the e.ErrorCode and e.ErrorDescription.
I don't think that "pinning" the ad control at the bottom of a ScrollViewer is a good idea. You'd better place both the ScrollViewer and the AdControl inside a Grid with two rows.
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 have ZXing.Net.Mobile barcodes scanner with a custom overlay and some UI components implemented in Xamarin.Forms in one View.
Is it possible at all?
I assumed that this is possible and implemented this:
1. Android.Support.V4.App.FragmentActivity with a custom overlay for ZXing scanner.
2. Android Activity with a custom overlay for ZXing scanner.
3. Android PageRenderer with a custom overlay for ZXing scanner.
I was able to run all these variants, but I was not able to mix them with Xamarin.Forms UI.
Example:
Here is my ZXingScannerRendererPage.xaml in the shared project. I want to have "TEST BUTTON" button above Zxing Scanner view.
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage x:Name="RootPage"
BackgroundColor="{StaticResource BackgroundColor}"
xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:DataCollector" x:Class="DataCollector.ZXingScannerRendererPage">
<ContentPage.Content>
<StackLayout>
<Button Text="TEST BUTTON" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
But when I run the application with PageRenderer I can see for a second my layout with "TEST BUTTON" and then view jumps to ZXing scanner.
When I "press back" button, I can see my XAML layout with "TEST BUTTON". I think ZXing opens a new activity or something.
So, what I need is:
1. Embed ZXing.Net.Mobile barcodes scanner with custom overlay into my Xamarin.Forms ContentPage along with other Xamarin.Forms UI.
or
2. Embed Xamarin.Forms UI above view with ZXing.Net.Mobile barcodes scanner with a custom overlay.
How to accomplish this? Is it possible to embed PageRenderer/Fragment/View into Xamarin.Forms XAML?
Thanks!
How to accomplish this? Is it possible to embed PageRenderer/Fragment/View into Xamarin.Forms XAML?
You could embed the scanner view in between to other redundant BoxViews.
<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ZXingSample.PartialScreenScanning"
xmlns:zxing="clr-namespace:ZXing.Net.Mobile.Forms;assembly=ZXing.Net.Mobile.Forms"
Title="Partial screen">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<BoxView Grid.Row="0" BackgroundColor="Chocolate"/>
<zxing:ZXingScannerView Grid.Row="1" x:Name="_scanView" OnScanResult="Handle_OnScanResult" IsScanning="true"
WidthRequest="200" HeightRequest="200" />
<BoxView Grid.Row="2" BackgroundColor="Blue" />
</Grid>
You could download the source file from the GitHub. https://github.com/jfversluis/ZXingSample
This blog would be helpful as well. https://blog.verslu.is/xamarin/xamarin-forms-xamarin/scanning-generating-barcodes-zxing/
I think there is an identical thread in XF forum.
You may find some hints from my reply on it
https://forums.xamarin.com/discussion/176704/how-to-embed-zxing-scanner-in-pagerenderer-fragment-view-into-xamarin-forms-contentpage#latest
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 created code to show image in panorama page. There is designer of that page showing but when i execute the program with my emulator or on my windows phone 8 they both are doesn't showing that images. Images are edited in paint. what is the resolution to show image perfectly in grid ??
my code is:
<controls:PanoramaItem >
<Grid Margin="0,-120,0,0">
<Image HorizontalAlignment="Left" Height="612" VerticalAlignment="Top" Width="420" Source="/HubTilesPanorama;component/powers.jpg" Margin="0,102,0,0" />
</Grid >
</controls:PanoramaItem>