5

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

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

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

在安卓中:

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

1 回答 1

24

使用它来设置输入单元格的填充:

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;

Android中的填充:

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

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

于 2016-08-22T14:24:49.470 回答