2016-06-28 73 views

回答

4

我會做這樣的事情

<StackLayout Orientation="Horizontal" BackgroundColor="Gray"> 
     <Label Text="+995 |" BackgroundColor="Transparent" /> 
     <Editor Text="699999999" BackgroundColor="Transparent"></Editor> 
</StackLayout> 

一個水平stacklayout與前綴一個標籤和條目的編輯器。

正如你可以看到自己我爲我的應用程序使用相同的方法,以顯示選擇器旁邊的箭頭向下圖標。

enter image description here

var datectrl = new NoBorderPicker() 
       { 
        VerticalOptions = LayoutOptions.Center, 
        FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)) * FontSizes.EditFormControlFactor, 
        HeightRequest = 40, 
        BackgroundColor = Color.White, 
        HorizontalOptions = LayoutOptions.FillAndExpand, 

       }; 

       var icon = new IconView() 
       { 
        Source = "ic_keyboard_arrow_right_black_24dp", 
        Foreground = Palette._019, 
        VerticalOptions = LayoutOptions.Center, 
        HorizontalOptions = LayoutOptions.End, 
        Margin = new Thickness(0, 0, 5, 0) 
       }; 
       var stack = new StackLayout() 
       { 
        Orientation = StackOrientation.Horizontal, 
        Children = 
        { 
         datectrl, 
         icon 
        } 
       }; 

NoBorderPicker是一個定製的渲染,以消除邊界的選取器控件

[assembly: ExportRenderer(typeof(NoBorderPicker), typeof(CustomPicker))] 
namespace ThesisSFA.Droid.Renderers 
{ 
    public class CustomPicker : PickerRenderer 
    { 
     protected override void OnElementChanged(ElementChangedEventArgs<Picker> e) 
     { 
      base.OnElementChanged(e); 
      if (Control != null) 
      { 

       var customBG = new GradientDrawable(); 
       customBG.SetColor(Android.Graphics.Color.Transparent); 
       customBG.SetCornerRadius(3); 
       Control.SetBackground(customBG); 

       var custdatepicker = (NoBorderPicker) this.Element; 
       this.Control.TextSize = (float)custdatepicker.FontSize; 

      } 
     } 
    } 
} 
+0

完美工作,謝謝! – nicks

相關問題