Xamarin Forms Android EntryCell 下划线 [英] Xamarin Forms Android EntryCell Underline

查看:61
本文介绍了Xamarin Forms Android EntryCell 下划线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要删除此图片中的默认下划线EntryCell 示例

I need to remove the default underline as seen in this image EntryCell Example

我已经为 Android 创建了一个自定义渲染器,它在设备上运行良好.我可以为 EntryCells 以及其他 UI 调整着色.

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.

但是我需要去掉这条线,我使用了一个占位符来表明它是一个 EntryCell,所以我不希望这条线可见.需要添加什么来实现这一点

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;
        }

    }

}

推荐答案

对于试图删除下划线的其他人,请将其添加到您的 Android 自定义渲染器:

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));

这篇关于Xamarin Forms Android EntryCell 下划线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆