如何在xamarin.forms中将左右填充设置为条目单元格

Sum*_*ani 5 custom-renderer xamarin.forms

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

我在PCl中的自定义输入单元格:

<local:MyEntryCell Placeholder="Placeholder" PlaceholderColor="Grey" TextColor="Black"/>

MyEntryCell is the custom name of my entry cell.
Run Code Online (Sandbox Code Playgroud)

在我的PCL中,我有:

public class MyEntryCell:Entry
{

}
Run Code Online (Sandbox Code Playgroud)

在IOS中:

namespace CustomEntry.IOS
{
   public class MyEntryCellRenderer:EntryRenderer
    {
         // override onElementChanged
    }
}
Run Code Online (Sandbox Code Playgroud)

在Android中:

namespace CustomEntry.Droid
    {
       public class MyEntryCellRenderer:EntryRenderer
        {
             // override onElementChanged
        }
    }
Run Code Online (Sandbox Code Playgroud)

Him*_*edi 21

用于将填充设置为输入单元格:

在IOS中填充:

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;
Run Code Online (Sandbox Code Playgroud)

Android中的填充:

Control.SetPadding(15, 15, 15, 0);
Run Code Online (Sandbox Code Playgroud)

因此,您可以设置值以使文本从特定位置开始.