c# - 更改 Xamarin Forms 中 Entry 控件的焦点颜色

标签 c# android xaml xamarin.forms custom-controls

如何在 Xamarin 表单的 Entry 控件中更改焦点边框和光标颜色?在模拟器中是标准的红色?

我在我的 Android 项目中添加了这个

[assembly: ExportRenderer(typeof(CustomEntryControl), typeof(MyEntryRenderer))]
namespace MyApp.Droid
{
    public class MyEntryRenderer : EntryRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {
                Control.SetBackgroundColor(global::Android.Graphics.Color.LightGreen);
            }
        }
    }
}

但是找不到边框或光标的属性?

enter image description here

最佳答案

您可以在 style.xml 文件中更改 Android 项目中的 Entry 焦点颜色。路径为:Resources/values/styles.xml

然后,查看“colorAccent”属性以设置自定义颜色。

ColorAccent in Xamarin Android Project

关于c# - 更改 Xamarin Forms 中 Entry 控件的焦点颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46301150/

相关文章:

android - AdMob 中介(Android 和 iOS): how to force a network to test it?

wpf - 在 XAML 中关联 View 和 ViewModel 对,无需重复代码

c# - 。网。异步 HttpWebRequest 的最大数量

c# - 本地化 Windows Phone 8 'Application Title' 和 'Tile Title' 字符串

android - 摇动动画无法正常工作

java - 我如何找到两个地点之间旅行的距离和时间?

c# - 连接 C# 和 Microsoft Office 应用程序

c# - 改进从 Entity Framework 生成的查询

c# - 数据网格列绑定(bind)

c# - 为什么这个附加属性没有更新?