Xamarin Forms Shell TabBar Rounded Corner - xamarin.forms

I'd like to know if there's a renderer to allows me to use a rounded corner in the tabbar using Shell, like in the image above.

You could do it in your custom shellrenderer :
create the MyShellRenderer in your android project:
[assembly: ExportRenderer(typeof(AppShell), typeof(MyShellRenderer))]
namespace your namepace
{
class MyShellRenderer:ShellRenderer
{
public MyShellRenderer(Context context) : base(context)
{
}
protected override IShellBottomNavViewAppearanceTracker CreateBottomNavViewAppearanceTracker(ShellItem shellItem)
{
return new MyShellBottomNavViewAppearanceTracker();
}
}
}
define the MyShellBottomNavViewAppearanceTracker:
namespace ShellDemo.Droid
{
class MyShellBottomNavViewAppearanceTracker : IShellBottomNavViewAppearanceTracker
{
public void Dispose()
{
}
public void ResetAppearance(BottomNavigationView bottomView)
{
}
public void SetAppearance(BottomNavigationView bottomView, IShellAppearanceElement appearance)
{
bottomView.SetBackgroundResource(Resource.Drawable.bottombackground);
}
}
}
create the round corner drawable bottombackground.xml in your Resources/drawable:
<?xml version="1.0" encoding="utf-8" ?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#f00" />
<corners android:topLeftRadius="20dp"
android:topRightRadius="20dp"
/>
</shape>
the effect :
Update for ios:
the similar to android
MyShellRenderer:ShellRenderer class
[assembly: ExportRenderer(typeof(AppShell), typeof(MyShellRenderer))]
namespace your namepace
{
class MyShellRenderer:ShellRenderer
{
protected override IShellTabBarAppearanceTracker CreateTabBarAppearanceTracker()
{
return new MyShellTabBarAppearanceTrancker();
}
}
}
MyShellTabBarAppearanceTrancker class:
class MyShellTabBarAppearanceTrancker : IShellTabBarAppearanceTracker
{
public void Dispose()
{
}
public void ResetAppearance(UITabBarController controller)
{
}
public void SetAppearance(UITabBarController controller, ShellAppearance appearance)
{
UIBezierPath uIBezierPath = UIBezierPath.FromRoundedRect(controller.TabBar.Bounds, UIRectCorner.TopLeft | UIRectCorner.TopRight, new CoreGraphics.CGSize(30, 30));
CAShapeLayer cAShapeLayer = new CAShapeLayer();
cAShapeLayer.Frame = controller.TabBar.Bounds;
cAShapeLayer.Path = uIBezierPath.CGPath;
controller.TabBar.Layer.Mask = cAShapeLayer;
}
public void UpdateLayout(UITabBarController controller)
{
}
}

Related

Read variables from controller of fxml-file

I try to set the size of a pane with a value that is inside a variable of the controller but i always get a:
java.lang.IllegalAccessException: class javafx.fxml.FXMLLoader$ValueElement (in module javafx.fxml) cannot access a member of class blub.Blub with modifiers "private"
EDIT:
I tried to make a minimal reproducible example and made some changes according to your comments. still the same IllegalAccessException
startFXMain.java
public class startFXMain extends Application {
private static MRE myApp;
public static void main(String[] args) {
try {
myApp = MRE.getInstance(args);
Application.launch(args);
} catch (Exception e) {
e.printStackTrace();
}
}
#Override
public void start(Stage primaryStage) throws Exception {
myApp.start(primaryStage);
}
}
MRE.java
public class MRE extends Application {
private static MRE instance = null;
#Override
public void start(Stage startStage) throws Exception {
try {
new MREGUI(startStage);
} catch (Exception e) {
e.printStackTrace();
}
}
public static MRE getInstance(String[] args) {
if (Objects.nonNull(instance))
return instance;
else synchronized (MRE.class) {
if (Objects.isNull(instance))
instance = new MRE();
return instance;
}
}
public static MRE getInstance() { return instance; }
private MRE() {
}
}
MREGUI.java
public class MREGUI extends Application {
private GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment()
.getDefaultScreenDevice();
public int iScreenWidth = gd.getDisplayMode().getWidth();
public int iScreenHeight = gd.getDisplayMode().getHeight();
private Scene scMainScene;
private Pane pMainPane;
#Override
public void start(Stage stgMainStage) throws Exception {
this.initStage(stgMainStage);
this.initStartPane();
this.initStartScene(this.pMainPane);
stgMainStage.setScene(this.scMainScene);
stgMainStage.show();
}
private void initStage(Stage s) {
s.setX(0);
s.setY(0);
s.setOnCloseRequest(new EventHandler<WindowEvent>() {
#Override
public void handle(WindowEvent e) {
Platform.exit();
System.exit(0);
}
});
}
private void initStartPane() {
FXMLLoader loader = new FXMLLoader();
try {
URL xmlUrl = new File(System.getProperty("user.dir") + "\\src\\startwindow.fxml").toURI().toURL();
loader.setLocation(xmlUrl);
pMainPane = loader.load();
loader.setController(this);
} catch (MalformedURLException err) {
err.printStackTrace();
} catch (IOException err) {
err.printStackTrace();
}
}
private void initStartScene(Pane rootPane) {
scMainScene = new Scene(rootPane, iScreenHeight, iScreenWidth);
}
public MREGUI(Stage stgMainStage) {
try {
this.start(stgMainStage);
} catch (Exception err) {
err.printStackTrace();
}
}
private MREGUI() {
}
#FXML
public int getIScreenWidth() { return this.iScreenWidth; }
#FXML
public int getIScreenHeight() { return this.iScreenHeight; }
}
startwindow.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.Pane?>
<Pane layoutX="0" layoutY="0" minHeight="640" minWidth="480" prefHeight="${iScreenHeight}" prefWidth="${iScreenWidth}"
xmlns:fx="http://javafx.com/fxml" fx:controller="MREGUI">
<style>
-fx-background-color: blue;
</style>
</Pane>
The problem is that your no-arg constructor in MREGUI is private, so the FXMLLoader cannot construct an instance of the controller class.
Here is a working version with the code considerably cleaned up, and not relying on AWT classes, etc. This is still probably completely the wrong approach (why not just look up the screen size when you create the scene, and set the scene size as required?).
public class StartFXMain {
public static void main(String[] args) {
Application.launch(MRE.class, args);
}
}
public class MRE extends Application {
#Override
public void start(Stage startStage) throws Exception {
try {
new MREGUI(startStage);
} catch (Exception e) {
e.printStackTrace();
}
}
public MRE() {
}
}
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.stage.Screen;
import javafx.stage.Stage;
import java.io.IOException;
import java.net.URL;
public class MREGUI {
private Screen screen = Screen.getPrimary();
private double screenWidth = screen.getVisualBounds().getWidth();
private double screenHeight = screen.getVisualBounds().getHeight();
private Scene mainScene;
private Pane mainPane;
public void start(Stage stgMainStage) throws Exception {
this.initStage(stgMainStage);
this.initStartPane();
this.initStartScene(this.mainPane);
stgMainStage.setScene(this.mainScene);
stgMainStage.show();
}
private void initStage(Stage s) {
s.setX(0);
s.setY(0);
}
private void initStartPane() {
FXMLLoader loader = new FXMLLoader();
try {
URL xmlUrl = getClass().getResource("startwindow.fxml");
loader.setLocation(xmlUrl);
mainPane = loader.load();
// this has no effect after loading the FMXL:
// loader.setController(this);
} catch (IOException err) {
err.printStackTrace();
}
}
private void initStartScene(Pane rootPane) {
mainScene = new Scene(rootPane, screenHeight, screenWidth);
}
public MREGUI(Stage stgMainStage) {
try {
this.start(stgMainStage);
} catch (Exception err) {
err.printStackTrace();
}
}
public MREGUI() {
}
public double getScreenWidth() { return this.screenWidth; }
public double getScreenHeight() { return this.screenHeight; }
}
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.Pane?>
<Pane layoutX="0" layoutY="0" minHeight="640" minWidth="480" prefHeight="${screenHeight}" prefWidth="${screenWidth}"
xmlns:fx="http://javafx.com/fxml" fx:controller="org.jamesd.examples.sizing.MREGUI">
<style>
-fx-background-color: blue;
</style>
</Pane>
If you need the controller to be the previously-constructed instance of the class, you have to set the controller prior to loading the FXML:
public class MREGUI {
// ...
private void initStartPane() {
FXMLLoader loader = new FXMLLoader();
try {
URL xmlUrl = getClass().getResource("startwindow.fxml");
loader.setLocation(xmlUrl);
loader.setController(this);
mainPane = loader.load();
} catch (IOException err) {
err.printStackTrace();
}
}
// ...
public MREGUI(Stage stgMainStage) {
try {
this.start(stgMainStage);
} catch (Exception err) {
err.printStackTrace();
}
}
// public MREGUI () {
//
// }
// ...
}
In order for this to work, you must remove the fx:controller attribute from the root element of the FXML. This attribute instructs the FXMLLoader to create an instance of the controller class by calling the no-argument constructor, which is incompatible with setting the controller in code:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.Pane?>
<Pane layoutX="0" layoutY="0" minHeight="640" minWidth="480" prefHeight="${screenHeight}" prefWidth="${screenWidth}"
xmlns:fx="http://javafx.com/fxml" >
<style>
-fx-background-color: blue;
</style>
</Pane>

Automatic height of the webview

I have a xamarin forms application and I have inserted a webview inside the layout stack, the problem is that I have multiple pages and in each page the length of the content is different from the others.
I wanted to ask if there was a way to have the webview automatically adjust the height.
I have read other similar questions on the site, but I admit they seemed confusing to me.
This is my code xaml
<ContentPage.Content>
<StackLayout Padding="0" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" Spacing="0" BackgroundColor="White">
<WebView
x:Name="wvSite"
VerticalOptions="FillAndExpand"
HeightRequest="2300" />
</StackLayout>
</ContentPage.Content>
You could reset the webview height according to the content height when loading page finished via custom renderer.
Android:
[assembly: ExportRenderer(typeof(WebView), typeof(CustomWebViewRenderer))]
namespace App1.Droid
{
public class CustomWebViewRenderer : WebViewRenderer
{
public CustomWebViewRenderer(Context context) : base(context)
{
}
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.WebView> e)
{
base.OnElementChanged(e);
Control.SetWebViewClient(new CustomWebViewClient(e.NewElement));
}
}
internal class CustomWebViewClient : Android.Webkit.WebViewClient
{
private WebView webView;
public CustomWebViewClient(WebView webView)
{
this.webView = webView;
}
public async override void OnPageFinished(Android.Webkit.WebView view, string url)
{
if (webView != null)
{
int i = 10;
while (view.ContentHeight == 0 && i-- > 0)
await System.Threading.Tasks.Task.Delay(100);
webView.HeightRequest = view.ContentHeight;
}
base.OnPageFinished(view, url);
}
}
}
iOS:
[assembly: ExportRenderer(typeof(WebView),
typeof(CustomWebviewRenderer))]
namespace App1.iOS
{
public class CustomWebviewRenderer : WkWebViewRenderer
{
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
NavigationDelegate = new CustomWebviewNavigationDelegate();
}
}
internal class CustomWebviewNavigationDelegate : WKNavigationDelegate
{
[Export("webview:didFinishNavigation:")]
public override void DidFinishNavigation(WKWebView webView, WKNavigation navigation)
{
//base.DidFinishNavigation(webView, navigation);
webView.Frame = new CoreGraphics.CGRect(0, 0, webView.ScrollView.ContentSize.Width, webView.ScrollView.ContentSize.Height);
}
}
}

Xamarin.Forms : Need to go back to previous page on back button press even if entry has focus

If my entry field has focus and i click on hardware back button, the entry field looses focus but i am not able to navigate to previous page. I have to hit the back button again. I know this is the expected behaviour, but i need to navigate to the previous page on the first back button press itself. Need some help regarding this.
This behavior is by design.But you could use custom renderer and custom a EditText to achieve the effect.
1.create a CustomEntry :
public partial class CustomEntry:Entry
{
public static readonly BindableProperty BackPressProperty=BindableProperty.Create("BackPress", typeof(EventHandler), typeof(CustomEntry), null);
public event EventHandler BackPress;
public void OnBack()
{
EventHandler eventHandler = this.BackPress;
eventHandler?.Invoke((object)this, EventArgs.Empty);
}
}
2.create a custom EditText MyEditText in your Android project:
class MyEditText: FormsEditText
{
public MyEditText(Context context) : base(context)
{
}
public override bool OnKeyPreIme([GeneratedEnum] Keycode keyCode, KeyEvent e)
{
if (keyCode == Keycode.Back)
{
if (listener != null)
{
listener.onKeyBack();
return true;
}
}
return base.OnKeyPreIme(keyCode, e);
}
private OnEditTextKeyBackListener listener;
public void setOnEditTextKeyBackListener(OnEditTextKeyBackListener listener)
{
this.listener = listener;
}
public interface OnEditTextKeyBackListener
{
void onKeyBack();
}
}
3.custom EntryRenderer MyEntryRenderer:
[assembly: ExportRenderer(typeof(CustomEntry), typeof(MyEntryRenderer))]
namespace EntryCa.Droid
{
class MyEntryRenderer:EntryRenderer,OnEditTextKeyBackListener
{
private Context context;
private EditText editText;
public MyEntryRenderer(Context context) : base(context)
{
this.context = context;
}
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
MyEditText editText = new MyEditText(context);
editText.setOnEditTextKeyBackListener(this);
editText.SetSingleLine(true); //this and below line to set done key
editText.ImeOptions = ImeAction.Done;
SetNativeControl(editText);
}
public void onKeyBack()
{
hideSoftInput();
((CustomEntry)Element).OnBack();
}
InputMethodManager mInputMethodManager = (InputMethodManager)Android.App.Application.Context.GetSystemService(Context.InputMethodService);
public void hideSoftInput()
{
if (mInputMethodManager != null)
{
mInputMethodManager.HideSoftInputFromWindow(WindowToken, HideSoftInputFlags.NotAlways);
}
}
}
}
4.use in your page.xaml:
<local:CustomEntry HorizontalOptions="StartAndExpand" WidthRequest="200" BackPress="CustomEntry_BackPress"></local:CustomEntry>
in your page.xaml.cs:
private void CustomEntry_BackPress(object sender, EventArgs e)
{
Navigation.PopAsync();
}

The underline of entry cannot removed

I want to make a entry that without underline. I tried two solutions but both can not work well.
Control.Background = null;
it is not go well and I take another solution:
GradientDrawable gd = new GradientDrawable();
gd.SetColor(global::Android.Graphics.Color.Transparent);
Control.SetBackground(gd);
this.Control.SetRawInputType(Android.Text.InputTypes.TextFlagNoSuggestions);
Control.SetHintTextColor(ColorStateList.ValueOf(global::Android.Graphics.Color.White));
It also not go well in android but work well in ios.I do not understand why.
You can try add xml styling named editText_bg.xml,
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="#FFFFFF" />
<stroke
android:width="1dp"
android:color="#2f6699" />
<corners
android:radius="10dp"
/>
</shape>
And you can give this to entry as background resource :
[assembly: ExportRenderer(typeof(CustomEntry), typeof(AndroidCustomEntryRenderer))]
namespace XXX.Droid.Renderer
{
public class AndroidCustomEntryRenderer : EntryRenderer
{
public AndroidCustomEntryRenderer(Context context) : base(context)
{
}
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (Control != null)
{
Control.SetBackgroundColor(global::Android.Graphics.Color.White);
Control.SetBackgroundResource(Resource.Drawable.edittext_bg);
}
}
}
}
Try my implementation(working for Android and ios). PlainEntry is empty class inherited from Xamarin.Forms.Entry
Android
[assembly: ExportRenderer(typeof(PlainEntry), typeof(PlainEntryRenderer))]
namespace UR.Droid.Renderers
{
public class PlainEntryRenderer : EntryRenderer
{
public PlainEntryRenderer(Context context) : base(context)
{
}
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (Control != null)
{
this.Control.
SetBackgroundColor(global::Android.Graphics.Color.Transparent);
Control.SetPadding(0, 0, 0, 0);
}
}
}
}
iOS
[assembly: ExportRenderer(typeof(PlainEntry), typeof(PlainEntryRenderer))]
namespace UR.iOS.Renderer
{
class PlainEntryRenderer: EntryRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (Control != null)
{
Control.BorderStyle = UITextBorderStyle.None;
Control.BackgroundColor = UIColor.FromRGBA(0, 0, 0, 0);
}
}
}
}
If you want to use renderers for all Xamarin.Forms.Entry like not the than specify:
[assembly: ExportRenderer(typeof(Xamarin.Forms.Entry), typeof(PlainEntryRenderer))]

Xamarin Forms : Hide Editor or Entry underline

I am using an editor in my UI. But the black underline is irritating, is there any way to remove that underline?
Thanks in advance
I have done the entry and editor underline removal features using custom renders.
##In PCL##
CustomEntry.cs
using Xamarin.Forms;
namespace Entry_Editor_Sample
{
public class CustomEntry : Entry
{
}
}
CustomEditor.cs
using Xamarin.Forms;
namespace Entry_Editor_Sample
{
public class CustomEditor : Editor
{
}
}
##In android##
CustomEntryRenderer.cs
using Android.Content;
using Android.Content.Res;
using Android.Graphics.Drawables;
using Android.Text;
using Entry_Editor_Sample;
using Entry_Editor_Sample.Droid;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(CustomEntry), typeof(CustomEntryRenderer))]
namespace Entry_Editor_Sample.Droid
{
class CustomEntryRenderer : EntryRenderer
{
public CustomEntryRenderer(Context context) : base(context)
{
}
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (Control != null)
{
GradientDrawable gd = new GradientDrawable();
gd.SetColor(global::Android.Graphics.Color.Transparent);
this.Control.SetBackgroundDrawable(gd);
this.Control.SetRawInputType(InputTypes.TextFlagNoSuggestions);
//Control.SetHintTextColor(ColorStateList.ValueOf(global::Android.Graphics.Color.White));
}
}
}
}
CustomEditorRenderer.cs
using Android.Content;
using Android.Content.Res;
using Android.Graphics.Drawables;
using Android.Text;
using Entry_Editor_Sample;
using Entry_Editor_Sample.Droid;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(CustomEditor), typeof(CustomEditorRenderer))]
namespace Entry_Editor_Sample.Droid
{
class CustomEditorRenderer : EditorRenderer
{
public CustomEditorRenderer(Context context) : base(context)
{
}
protected override void OnElementChanged(ElementChangedEventArgs<Editor> e)
{
base.OnElementChanged(e);
if (Control != null)
{
GradientDrawable gd = new GradientDrawable();
gd.SetColor(global::Android.Graphics.Color.Transparent);
this.Control.SetBackgroundDrawable(gd);
this.Control.SetRawInputType(InputTypes.TextFlagNoSuggestions);
//Control.SetHintTextColor(ColorStateList.ValueOf(global::Android.Graphics.Color.Black));
}
}
}
}
##In IOS##
CustomEntryRenderer.cs
using Entry_Editor_Sample;
using Entry_Editor_Sample.iOS;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(CustomEntry), typeof(CustomEntryRenderer))]
namespace Entry_Editor_Sample.iOS
{
class CustomEntryRenderer : EntryRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (Control != null)
{
Control.BorderStyle = UITextBorderStyle.None;
Control.Layer.CornerRadius = 10;
//Control.TextColor = UIColor.Black;
}
}
}
}
CustomEditorRenderer.cs
using Entry_Editor_Sample;
using Entry_Editor_Sample.iOS;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(CustomEditor), typeof(CustomEditorRenderer))]
namespace Entry_Editor_Sample.iOS
{
class CustomEditorRenderer : EditorRenderer
{
public CustomEditorRenderer()
{
UIKeyboard.Notifications.ObserveWillShow((sender, args) =>
{
if (Element != null)
{
Element.Margin = new Thickness(0, 0, 0, args.FrameEnd.Height); //push the entry up to keyboard height when keyboard is activated
}
});
UIKeyboard.Notifications.ObserveWillHide((sender, args) =>
{
if (Element != null)
{
Element.Margin = new Thickness(0); //set the margins to zero when keyboard is dismissed
}
});
}
protected override void OnElementChanged(ElementChangedEventArgs<Editor> e)
{
base.OnElementChanged(e);
if (Control != null)
{
Control.Layer.CornerRadius = 10;
Control.TextColor = UIColor.Black;
}
}
}
}
##Finally in MainPage.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:local="clr-namespace:Entry_Editor_Sample"
mc:Ignorable="d"
BackgroundColor="White"
xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
ios:Page.UseSafeArea="true"
x:Class="Entry_Editor_Sample.MainPage">
<StackLayout
VerticalOptions="CenterAndExpand"
HorizontalOptions="FillAndExpand"
BackgroundColor="White">
<local:CustomEntry
BackgroundColor="SkyBlue"
Placeholder="Entry"
PlaceholderColor="Black"
TextColor="Black"/>
<local:CustomEditor
BackgroundColor="SkyBlue"
Placeholder="Editor"
HeightRequest="100"
PlaceholderColor="Black"
TextColor="Black"/>
</StackLayout>
</ContentPage>
I uploaded a sample on here :)
Create a custom renderer in your Android project:
public class CustomEntryRenderer : EntryRenderer {
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e) {
base.OnElementChanged(e);
Control.SetBackgroundColor(Android.Graphics.Color.Transparent);
}
}
Then in your XAML:
<ContentPage xmlns:xyz="clr-namespace:PclNamespaceForCustomControls">
...
<xyz:CustomEntry Placeholder="Lorem ipsum" />
</ContentPage>
See Microsoft docs for more info: https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/custom-renderer/entry
You can use custom renderers to achieve entry and editor underline removal.
I am using the below code to apply these feature for all entries and editors in the project and it is working with Xamarin Forms 4.8+
Xamarin Android
Entry
[assembly: ExportRenderer(typeof(Entry), typeof(EntryRendererAndroid), new[] { typeof(VisualMarker.DefaultVisual) })]
namespace XFTest.Droid.Renderers
{
public class EntryRendererAndroid : EntryRenderer
{
public EntryRendererAndroid(Context context) : base(context) { }
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (Control != null)
{
Control.Background = null;
Control.SetBackgroundColor(Android.Graphics.Color.Transparent);
}
}
}
}
Editor
[assembly: ExportRenderer(typeof(Editor), typeof(EditorRendererAndroid), new[] { typeof(VisualMarker.DefaultVisual) })]
namespace XFTest.Droid.Renderers
{
public class EditorRendererAndroid : EditorRenderer
{
public EditorRendererAndroid(Context context) : base(context) { }
protected override void OnElementChanged(ElementChangedEventArgs<Editor> e)
{
base.OnElementChanged(e);
if (Control != null)
{
Control.Background = null;
Control.SetBackgroundColor(Android.Graphics.Color.Transparent);
}
}
}
}
Xamarin iOS
Entry
[assembly: ExportRenderer(typeof(Entry), typeof(EntryRendereriOS), new[] { typeof(VisualMarker.DefaultVisual) })]
namespace XFTest.iOS.Renderers
{
public class EntryRendereriOS : EntryRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (Control != null)
{
Control.BackgroundColor = UIColor.FromWhiteAlpha(1, 1);
Control.Layer.BorderWidth = 0;
Control.BorderStyle = UITextBorderStyle.None;
}
}
}
}
Editor
[assembly: ExportRenderer(typeof(Entry), typeof(EntryRendereriOS), new[] { typeof(VisualMarker.DefaultVisual) })]
namespace XFTest.iOS.Renderers
{
public class EntryRendereriOS : EntryRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (Control != null)
{
Control.BackgroundColor = UIColor.FromWhiteAlpha(1, 1);
Control.Layer.BorderWidth = 0;
Control.BorderStyle = UITextBorderStyle.None;
}
}
}
}

Resources