2016-08-22 84 views
1

中的入口單元格我已經使用xamarin表單中IOS和android的入口單元格的自定義呈現。如何爲輸入單元格設置左側和右側填充。 PCL中如何設置左右填充到xamarin.forms

我自進入細胞:

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

你的MyEntryCell繼承自什麼?你不能只用'Padding =「10,0,10,0」'? –

+0

入口單元沒有填充屬性 –

+0

那麼你可能需要在你的'MyEntryCell'中設置一些填充,你可以用你的'MyEntryCell'的代碼更新你的問題嗎? –

回答

6

使用此設置填充到一個條目單元:

填充在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; 

填充在安卓

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

因此,你可以設定值,使文本開始從具體位置。

+0

這就是我想要的。謝謝 ! –