如何在xamarin.forms中设置输入单元格的左右填充



我在IOS和android的xamarin表单中使用了自定义渲染的输入单元格。如何设置输入单元格的左右填充。

我的自定义输入单元格:

<local:MyEntryCell Placeholder="Placeholder" PlaceholderColor="Grey" TextColor="Black"/>
MyEntryCell is the custom name of my entry cell.

在我的PCL中我有:

public class MyEntryCell:Entry
{
}
在IOS:

namespace CustomEntry.IOS
{
   public class MyEntryCellRenderer:EntryRenderer
    {
         // override onElementChanged
    }
}

Android:

namespace CustomEntry.Droid
    {
       public class MyEntryCellRenderer:EntryRenderer
        {
             // override onElementChanged
        }
    }

用于设置输入单元格的内边距:

IOS中的Padding:

Control.LeftView = new UIView(new CGRect(0,0,15,0));
Control.LeftViewMode = UITextFieldViewMode.Always;
Control.RightView = new UIView(new CGRect(0, 0, 15, 0));
Control.RightViewMode = UITextFieldViewMode.Always;

Android:

Control.SetPadding(15, 15, 15, 0);

相应地,您可以设置该值,使文本从特定位置开始

最新更新