I'm work on changing iOS status bar color and it's text color. The result appeared good except when a pop-up shown on screen. As shown as the image below, the status bar does not dimmed when a pop-up displayed on screen, it seems to stand out on the screen.
As I really not familiar with iPhone, does it usually work this way? Or is there any workaround to dim status bar if pop-up appeared?
Note: I am using iPhone X with iOS 12.1
Pop-up Code:
<?xml version="1.0" encoding="utf-8" ?>
<pages:BasePopupPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="WhiteLabel.Mobile.App.Pages.Popup.TransferPopUp"
xmlns:pages="clr-namespace:WhiteLabel.Mobile.App.Pages.Popup"
xmlns:popups="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
xmlns:animations="clr-namespace:Rg.Plugins.Popup.Animations;assembly=Rg.Plugins.Popup"
xmlns:Resources="clr-namespace:WhiteLabel.Mobile.App.Resources">
<!--Animations use example-->
<popups:PopupPage.Animation>
<animations:ScaleAnimation
PositionIn="Center"
PositionOut="Center"
ScaleIn="1.2"
ScaleOut="0.8"
DurationIn="400"
DurationOut="300"
EasingIn="SinOut"
EasingOut="SinIn"
HasBackgroundAnimation="True"/>
</popups:PopupPage.Animation>
<!-- Content -->
<StackLayout
VerticalOptions="Center"
HorizontalOptions="FillAndExpand"
Padding="20, 20, 20, 20">
<StackLayout BackgroundColor="White">
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="60"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
</Grid>
<StackLayout >
<Label
Text="DELETE_POPUP_INFO"
HorizontalTextAlignment="Center"
VerticalTextAlignment="Center"/>
<Grid BackgroundColor="White" Padding="20, 20, 20, 20">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50*"/>
<ColumnDefinition Width="50*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<!-- Cancel button-->
<Button x:Name="CancelButton"
Command="{Binding TappedCloseCommand}"
Grid.Row="0"
Grid.Column="0"
Text="CANCEL"
BorderWidth="1"
BorderRadius="0">
<Button.BorderRadius>
<!-- fixes a bug on android where border doesn't work without a radius. -->
<OnPlatform x:TypeArguments="x:Int32">
<OnPlatform.Android>1</OnPlatform.Android>
</OnPlatform>
</Button.BorderRadius>
</Button>
<!-- Delete button-->
<Button x:Name="DeleteButton"
Command="{Binding TappedDeleteCommand}"
Grid.Row="0"
Grid.Column="1"
Text="DELETE"
WidthRequest="500"
BorderRadius="0">
</Button>
</Grid>
</StackLayout>
</StackLayout>
</StackLayout>
</pages:BasePopupPage>
I use your code and create a pop up page. It works as expected. I will show you the code I use and you can have a look at it.
Here is button event I use to show the pop-up:
private void Button_Clicked(object sender, EventArgs e)
{
PopupNavigation.Instance.PushAsync(new Page1());
}
And I did not add additional code in the pop up page:
public partial class Page1 : PopupPage
{
public Page1()
{
InitializeComponent();
}
}
The code in Xaml is the same as you and I use Rg.Plugins.Popup with version 1.1.5.188.
I can share you the sample if you want.
Here is the screenshot:
Related
I have a problem. I want to use an IconView to change the color of an Image, so I use this project: https://github.com/andreinitescu/IconApp.
Now I added the Renderers in both IOS and Android and I added the IconView.cs class to the project. In my xaml I am trying to use the following code:
<controls:IconView Source="ledstrip" Grid.RowSpan="2" Grid.Column="0" Margin="5" Foreground="Red" />
But when I run my app, nothing shows up and I have no clue what I am doing wrong? If I create the following Image:
<Image Source="ledstrip" Grid.RowSpan="2" Grid.Column="0" Margin="5" />
The image gets shown!
Here is my full XAML:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="clr-namespace:Bluepixel.Tools"
mc:Ignorable="d"
x:Class="Bluepixel.Pages.Devices">
<StackLayout Orientation="Vertical">
<ListView ItemsSource="{Binding knownDeviceList}" SelectionMode="None" RowHeight="90" ItemTapped="device_Clicked" x:Name="MyListView">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.ContextActions>
<MenuItem Command="{Binding Path=BindingContext.DeleteDevice, Source={x:Reference MyListView}}}"
CommandParameter="{Binding Id}"
Text="Delete" IsDestructive="True" />
</ViewCell.ContextActions>
<AbsoluteLayout HeightRequest="70" Margin="20,10,20,10">
<StackLayout Opacity="0.3" BackgroundColor="White"
AbsoluteLayout.LayoutBounds="0,0,1,1"
AbsoluteLayout.LayoutFlags="All" />
<StackLayout AbsoluteLayout.LayoutBounds="0,0,1,1"
AbsoluteLayout.LayoutFlags="All">
<Grid RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="35" />
<RowDefinition Height="35" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="70" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="70" />
</Grid.ColumnDefinitions>
<controls:IconView Source="ledstrip" Grid.RowSpan="2" Grid.Column="0" Margin="5" Foreground="Red" />
</Grid>
</StackLayout>
</AbsoluteLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage>
What am I doing wrong?
The library is not use to change the color of an Image, if you see the source code in the renderer in the iOS project, it changes the tintColor of UIImage in iOS:
var uiImage = new UIImage(Element.Source);
uiImage = uiImage.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate);
Control.TintColor = Element.Foreground.ToUIColor();
Control.Image = uiImage;
You can see the document and this thread to know how tint color works.
After some test, I found if you use a image which background is transparent, the image will show successfully with this plugin.
I uploaded a sample project here and there are several images you can test under resource folder. I think it's the same behavior in Android.
My UI looks different on both devices that I'm running my app on , which is normal , but I want to adapt it to both OS (iOS and Android) ,
I tried using StackLayout inside the Grids but nothing is changing , my UI is still not responsive .
<?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="interface_test.Login" BackgroundColor="#E7695C">
<ContentPage.Content>
<Grid BackgroundColor="#E7695C">
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="*"/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<StackLayout Orientation="Horizontal" HorizontalOptions="Center" Margin="0,10,0,0" Grid.Row="0">
</StackLayout>
<Grid Grid.Row="1" Margin="20,0,20,0">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="50"/>
<RowDefinition Height="50"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Image Source="arrow.png" HeightRequest="70" VerticalOptions="EndAndExpand"/>
<Entry Grid.Row="1" Placeholder="Email or Phone Number" PlaceholderColor="#bababa" FontSize="16"/>
<Entry Grid.Row="2" Placeholder="Password" PlaceholderColor="#bababa" FontSize="16" IsPassword="true"/>
<Button Clicked="Handle_Clicked" Text="Log In" BackgroundColor="#2B3D4F" TextColor="White" HeightRequest="50"
VerticalOptions="Start" Grid.Row="3" />
<Grid Grid.Row="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label BackgroundColor="#bababa" HeightRequest="1" HorizontalOptions="FillAndExpand" VerticalOptions="Center" />
<!--<Label Text="" Grid.Column="1" VerticalOptions="Center" Margin="10,0,10,0"/>-->
<Image Source="facebook.png" Grid.Column="1" VerticalOptions="Center" Margin="10,0,10,0"/>
<Label BackgroundColor="#bababa" Grid.Column="2" HeightRequest="1" HorizontalOptions="FillAndExpand"
VerticalOptions="Center" />
</Grid>
<StackLayout Orientation="Horizontal" HorizontalOptions="CenterAndExpand" Grid.Row="6">
<Label Text="Connectez-vous avec Facebook" TextColor="#2B3D4F" />
</StackLayout>
</Grid>
<StackLayout Grid.Row="2" BackgroundColor="#2B3D4F">
<Label Text="Créer un compte" VerticalOptions="FillAndExpand" TextColor="White" VerticalTextAlignment="Center"
HorizontalTextAlignment="Center" />
</StackLayout>
</Grid>
</ContentPage.Content>
</ContentPage>
here's an example of what I got:
Android :
iPhone :
And I would love if my Android interface will look as the iPhones's.
you could use Custom Renderer to cutom the Control, for example(Entry):
1.custom MyEntry :
public class MyEntry :Entry
{
}
2.in *.Android create MyEntryRenderer :
[assembly: ExportRenderer(typeof(MyEntry), typeof(MyEntryRenderer))]
namespace App11.Droid
{
class MyEntryRenderer : EntryRenderer
{
public MyEntryRenderer(Context context) : base(context)
{
}
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (Control != null)
{
// custom your style
Control.SetBackgroundResource(Resource.Drawable.edittext_shape);
}
}
}
}
in Resources/drawable create the xml (here called edittext_shape,which set the rounded corners of entry)
<?xml version="1.0" encoding="utf-8" ?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="#fff" />
<corners android:radius="5dp" />
</shape>
3.use in page's xaml :
<ContentPage ...
xmlns:local="clr-namespace:*;assembly=*"
...>
...
<local:MyEntry Placeholder="Email or Phone Number" PlaceholderColor="#bababa" FontSize="16"/>
...
</ContentPage>
More information can be found here:CustomRenderer
I have a segment control where I'm displaying tabs. But I'm not able to edit the style of the tab in Xamarin Forms. This is the UI I want
This is how I want to display my tabs in the segment control. I'm able to change the tint color, background color, and text color but none of that will get me a tab in this style. This is my current UI
This is XAML code where I implemented the segment control
<controls:SegmentedControl BackgroundColor="White" SelectedTextColor="Black" TintColor="#FFA500" x:Name="SegControl" ValueChanged="Handle_ValueChanged">
<controls:SegmentedControl.Children>
<controls:SegmentedControlOption Text="VENDOR NAME" />
<controls:SegmentedControlOption Text="PRODUCT/SERVICE" />
</controls:SegmentedControl.Children>
</controls:SegmentedControl>
<StackLayout x:Name="SegContent" />
</StackLayout>
<StackLayout Margin="0,30,0,0">
<StackLayout AbsoluteLayout.LayoutBounds=".20,1,1,.1" AbsoluteLayout.LayoutFlags="All" BackgroundColor="White" HorizontalOptions="FillAndExpand" Orientation="Horizontal">
<StackLayout Style="{StaticResource ButtonNavigationBarStackLayoutStyle}" x:Name="stckNear">
<Image Margin="0,10,0,10" x:Name="imgNear" Style="{StaticResource ButtonNavigationBarImageStyle}" />
<Label Text="Near" Style="{StaticResource ButtonNavigationBarLabelStyle}"></Label>
</StackLayout>
<StackLayout Style="{StaticResource ButtonNavigationBarStackLayoutStyle}" x:Name="stckSearch">
<Image Margin="0,10,0,10" x:Name="imgSearch" Style="{StaticResource ButtonNavigationBarImageStyle}" />
<Label Text="Search" Style="{StaticResource ButtonNavigationBarLabelStyle}"></Label>
</StackLayout>
<StackLayout Style="{StaticResource ButtonNavigationBarStackLayoutStyle}" x:Name="stckCart">
<Image Margin="0,10,0,10" x:Name="imgCart" Style="{StaticResource ButtonNavigationBarImageStyle}" />
<Label Text="Cart" Style="{StaticResource ButtonNavigationBarLabelStyle}"></Label>
</StackLayout>
<StackLayout Style="{StaticResource ButtonNavigationBarStackLayoutStyle}" x:Name="stckAccount">
<Image Margin="0,10,0,10" x:Name="imgAccount" Style="{StaticResource ButtonNavigationBarImageStyle}" />
<Label Text="Account" Style="{StaticResource ButtonNavigationBarLabelStyle}"></Label>
</StackLayout>
</StackLayout>
I'm not using any custom renderer for this segment control. Do I have to use a custom renderer for implementing the required UI? If yes how? Any suggestions?
SegmentedControl is not a built in Xamarin.Forms control. There are a few libraries that offer a SegmentedControl, so it would help to know which one you are using.
That said, the library author who created that SegmentedControl also made the platform renderers and so the different look on iOS vs Android is a result of that.
You can, of course, create your own custom renderer, but then why use the library?
Easier to me would be to make a control using Xamarin Forms, for instance you can use a grid that has a first row of two labels ( or Buttons) and a second row of 2 BoxViews that can act as the underline (very short height). Then just add TapGestureRecognizers to each Label (or just use a Buttons and style as needed).
Here's an example using Buttons and BoxViews:
XAML:
<Grid Padding="10">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button x:Name="vBtn"
Text="VENDOR NAME" Clicked="Handle_Clicked"
TextColor="Black"
BackgroundColor="Transparent"
BorderColor="Transparent"
Grid.Row="0"
Grid.Column="0"/>
<Button x:Name="pBtn"
Text="PRODUCT/SERVICE" Clicked="Handle_Clicked"
TextColor="Black"
BackgroundColor="Transparent"
BorderColor="Transparent"
Grid.Row="0"
Grid.Column="1" />
<BoxView x:Name="vBox"
Color="#FFA500" HeightRequest="5"
Grid.Row="1"
Grid.Column="0"/>
<BoxView x:Name="pBox"
Color="Silver" HeightRequest="5"
Grid.Row="1"
Grid.Column="1"/>
</Grid>
Code behind:
void Handle_Clicked(object sender, System.EventArgs e)
{
Button btn = sender as Button;
if (btn.Text == "PRODUCT/SERVICE")
{
vBox.Color = Color.Silver;
pBox.Color = Color.FromHex("#FFA500");
// Do anything else you need to do when the PRODUCT/SERVICE is tapped
}
else
{
vBox.Color = Color.FromHex("#FFA500");
pBox.Color = Color.Silver;
// Do anything else you need to do when the VENDOR NAME is tapped
}
}
No library or custom renderer needed.
I changed the height of my progress bar with this custom rederer:
public class CustomProgressBarRenderer : ProgressBarRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.ProgressBar> e)
{
base.OnElementChanged(e);
Control.ProgressTintColor = Color.FromRgb(182, 231, 233).ToUIColor();// This changes the color of the progress
}
public override void LayoutSubviews()
{
base.LayoutSubviews();
var X = 1.0f;
var Y = 10.0f; // This changes the height
CGAffineTransform transform = CGAffineTransform.MakeScale(X, Y);
Control.Transform = transform;
}
}
I use my custom progress bar in a Grid. The problem is, I can't see the custom progress bar. It looks like the progress bar is on top of the page behind the other control. Because if i put the progress bar inside a StackLayout with Margin="50" in the Grid, the progress bar appear. And then it looks like
In the Android App is everything fine. This proplem occours only in the IOS APP.
Does anybody has an idea how can I center the progress bar?
Thanks
Xaml code
<customPages:CommonToolbarPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MC.Core.Views.Learn.Simple.LearnSimpleView"
xmlns:viewModelBase="clr-namespace:MC.Core.ViewModels.Base;assembly=MC.Core"
xmlns:customPages="clr-namespace:MC.Core.CustomPage;assembly=MC.Core"
xmlns:control="clr-namespace:MC.Core.Controls;assembly=MC.Core"
xmlns:translator="clr-namespace:MC.Core.Helpers"
viewModelBase:ViewModelLocator.AutoWireViewModel="true"
Title="{Binding PageTitle}">
<ContentPage.ToolbarItems>
<ToolbarItem Command="{Binding RestartLearnCommand}" Text="{translator:Translate ButtonReset}" Priority="0" Order="Primary"></ToolbarItem>
</ContentPage.ToolbarItems>
<ContentPage.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="1"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<BoxView Grid.Row="0" HeightRequest="1" Style="{DynamicResource GreySeparatorLine}"></BoxView>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<!--Start ProgressBar Control-->
<ContentView Grid.Row="0" Grid.Column="0" Margin="10,0" >
<Grid Padding="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Grid.Column="0" Margin="1,0">
<Label Style="{DynamicResource RightVsWrongLabelStyle}" Text="{Binding CorrectVsWrongStatus}"></Label>
<Label Style="{DynamicResource LearnSystemLabelStyle}" Text="{translator:Translate LearnModusSimple}" ></Label>
</Grid>
<Grid Grid.Row="1" Grid.Column="0" Margin="1,5">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Grid.Column="0">
<StackLayout Margin="50">
<control:CustomProgressBar HeightRequest="10" x:Name="progressBar" Progress="{Binding LearnProgressValue}"></control:CustomProgressBar>
<Label Style="{DynamicResource ProgressBarLabelStyle}" Text="{Binding LabelProgressStatus}"></Label>
</StackLayout>
</Grid>
</Grid>
</Grid>
<ContentView.Triggers>
<DataTrigger TargetType="ContentView" Binding="{Binding ShowProgressBar}" Value="false">
<Setter Property="IsVisible" Value="false"></Setter>
</DataTrigger>
<DataTrigger TargetType="ContentView" Binding="{Binding ShowProgressBar}" Value="true">
<Setter Property="IsVisible" Value="true"></Setter>
</DataTrigger>
</ContentView.Triggers>
</ContentView>
<!--End ProgressBar Control-->
<!-- ... Some other code ... -->
</Grid>
</Grid>
</ContentPage.Content>
Hi Guys probably very easy question for Xamarin expert I am trying to vertically center align stacklayout control and it is working fine in android mobile but not working in windows mobile device. My code is below
<?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="aa.Views.MainPage">
<ScrollView>
<StackLayout Orientation="Vertical" VerticalOptions="CenterAndExpand"
Padding="20" Spacing="10">
<Entry x:Name="enEmail" Placeholder="Email"></Entry>
<Entry x:Name="enPassword" IsPassword="True" Placeholder="Password"></Entry>
<Button Text="Login" Clicked="OnClicked_btnLogin" x:Name="btnLogin"></Button>
<Button Text="Register" Clicked="OnClicked_btnRegister" x:Name="btnRegister"></Button>
</StackLayout>
</ScrollView>
</ContentPage>
For more details please have a look at the attached images and help me how would i align it in center of screen for windows phone
its StackLayout: puts views consecutive one another. If you want to move buttons to down side use Grid instead like:
<Grid RowSpacing="10"><!--RowSpacing gives some space between rows-->
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/> <!--You can also use constant size also-->
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/> <!--This fill the empty space-->
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Entry Grid.Row="0" Placeholder=" Email"/>
<Entry Grid.Row="1" Placeholder=" Password" IsPassword="True"/>
<Button Grid.Row="3" Text="Login" />
<Button Grid.Row="4" Text="Register" />
</Grid>
Try the code below, it will give you a scroll view plus your fields will be aligned to the center
<ScrollView>
<AbsoluteLayout>
<StackLayout Orientation="Vertical" AbsoluteLayout.LayoutBounds="0, 0, 1, 1" AbsoluteLayout.LayoutFlags="All" x:Name="maincontent" Spacing="0">
<StackLayout Orientation="Vertical" VerticalOptions="CenterAndExpand"
Padding="20" Spacing="10">
<Entry x:Name="enEmail" Placeholder="Email"></Entry>
<Entry x:Name="enPassword" IsPassword="True" Placeholder="Password"></Entry>
<Button Text="Login" Clicked="OnClicked_btnLogin" x:Name="btnLogin"></Button>
<Button Text="Register" Clicked="OnClicked_btnRegister" x:Name="btnRegister"></Button>
</StackLayout>
</StackLayout>
</AbsoluteLayout>
</ScrollView>