【问题标题】:How to set the border color for visual material entry using xamarin forms?如何使用 xamarin 表单设置视觉材料输入的边框颜色?
【发布时间】:2021-09-05 23:47:33
【问题描述】:

我们正在为我们的项目使用视觉材料条目。

using Xamarin.Forms.Material.Android;

[assembly: ExportRenderer(typeof(Entry), typeof(CustomMaterialEntryRenderer ), new[] { typeof(VisualMarker.MaterialVisual) })]
namespace MyApp.Android
{
    public class CustomMaterialEntryRenderer : MaterialEntryRenderer
    {
        //...
    }
}

如何设置入口的边框颜色?

【问题讨论】:

  • 您的意思是要更改下划线颜色吗?
  • 没有。我想更改指示的边框颜色
  • 您是否尝试使用PlaceholderColor

标签: c# xamarin xamarin.forms xamarin.android xamarin.ios


【解决方案1】:

你需要创建一个样式

<style name="TextInputLayoutStyle" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense">
    <item name="boxStrokeColor">{color}</item>
    <item name="boxStrokeWidth">{strokeWidth}</item>
</style>

在整个应用程序中设置样式

<item name="textInputStyle">@style/TextInputLayoutTheme</item>

如果您只想在某些控件中使用样式,则必须在渲染器中创建本机控件并通过构造函数传递样式

【讨论】:

    猜你喜欢
    • 2021-08-28
    • 2020-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多