Xamarin Forms Android EntryCell Underline

前提是你 提交于 2019-12-24 17:33:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!