问题
I need to remove the default underline as seen in this image EntryCell Example
I have already created a custom Renderer for Android which is working fine on the device. I am able to color the EntryCells
along with other UI tweaks.
However I need to get rid of the line, I am using a placeholder to make it obvious that it is an EntryCell
so I don't want the line to be visible. What needs to be added to achieve this
using System;
using System.ComponentModel;
using Android.Content;
using Android.Views;
using Android.Widget;
using App.Droid.CustomRenderer;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
using EntryCellRenderer = App.Droid.CustomRenderer.EntryCellRenderer;
[assembly: ExportRenderer(typeof(EntryCell), typeof(EntryCellRenderer))]
namespace App.Droid.CustomRenderer
{
public class EntryCellRenderer : Xamarin.Forms.Platform.Android.EntryCellRenderer
{
protected override Android.Views.View GetCellCore(Cell item, Android.Views.View convertView, ViewGroup parent, Context context)
{
var cell = base.GetCellCore(item, convertView, parent, context) as EntryCellView;
if (cell != null)
{
var textField = cell.EditText as TextView;
textField.SetTextSize(Android.Util.ComplexUnitType.Dip, 20);
textField.SetTextColor(Color.FromHex("#FF8800").ToAndroid());
cell.SetBackgroundColor(Color.FromHex("#FF8800").ToAndroid());
}
return cell;
}
}
}
回答1:
For anyone else trying to remove the underline, add this to your Android Custom Renderer:
textField.SetBackgroundColor(Android.Graphics.Color.Argb(0, 0, 0, 0));
来源:https://stackoverflow.com/questions/54103422/xamarin-forms-android-entrycell-underline