protected override void OnElementChanged(ElementChangedEventArgs <TimePicker> e) { base.OnElementChanged(e); if (e.OldElement == null) { Control.Background = null; var layoutParams = new MarginLayoutParams(Control.LayoutParameters); layoutParams.SetMargins(0, 0, 0, 0); LayoutParameters = layoutParams; Control.LayoutParameters = layoutParams; Control.SetPadding(0, 0, 0, 0); SetPadding(0, 0, 0, 0); BorderlessTimePicker element = Element as BorderlessTimePicker; if (element.Time == TimeSpan.Zero && !String.IsNullOrEmpty(element.Placeholder)) { Control.Text = element.Placeholder; textColor = element.TextColor; placeholderColor = element.PlaceholderColor == default(Color) ? textColor : element.PlaceholderColor; element.TextColor = placeholderColor; Control.TextChanged += Control_TextChanged; } } }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.DatePicker> e) { base.OnElementChanged(e); if (e.OldElement == null) { Control.Background = null; string fontFamily = e.NewElement?.FontFamily; if (!string.IsNullOrEmpty(fontFamily)) { var label = (TextView)Control; // for example Typeface font = Typeface.CreateFromAsset(Forms.Context.Assets, fontFamily + ".otf"); label.Typeface = font; } var layoutParams = new MarginLayoutParams(Control.LayoutParameters); layoutParams.SetMargins(0, 0, 0, 0); LayoutParameters = layoutParams; Control.LayoutParameters = layoutParams; Control.SetPadding(0, 0, 0, 0); SetPadding(0, 0, 0, 0); BorderlessDatePicker element = Element as BorderlessDatePicker; if (!string.IsNullOrWhiteSpace(element.Placeholder)) { Control.Text = element.Placeholder; } this.Control.TextChanged += (sender, arg) => { var selectedDate = arg.Text.ToString(); if (selectedDate == element.Placeholder) { Control.Text = DateTime.Now.ToString("dd/MM/yyyy"); } }; } }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.DatePicker> e) { base.OnElementChanged(e); if (e.OldElement == null) { Control.Background = null; var layoutParams = new MarginLayoutParams(Control.LayoutParameters); layoutParams.SetMargins(0, 0, 0, 0); LayoutParameters = layoutParams; GradientDrawable gd = new GradientDrawable(); //gd.SetStroke(0, Android.Graphics.Color.Transparent); gd.SetColor(Element.BackgroundColor.ToAndroid()); gd.SetCornerRadius(Context.ToPixels(ElementV2.CornerRadius)); gd.SetStroke((int)Context.ToPixels(ElementV2.BorderThickness), ElementV2.BorderColor.ToAndroid()); var padTop = (int)Context.ToPixels(ElementV2.Padding.Top); var padBottom = (int)Context.ToPixels(ElementV2.Padding.Bottom); var padLeft = (int)Context.ToPixels(ElementV2.Padding.Left); var padRight = (int)Context.ToPixels(ElementV2.Padding.Right); Control.SetPadding(padLeft, padTop, padRight, padBottom); Control.Gravity = GravityFlags.Center; Control.SetBackground(gd); //Control.SetBackgroundDrawable(gd); Control.LayoutParameters = layoutParams; //Control.SetPadding(0, 0, 0, 0); //SetPadding(0, 0, 0, 0); } }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.TimePicker> e) { base.OnElementChanged(e); TimePickerDialogIntervals timePickerDlg = new TimePickerDialogIntervals(this.Context, new EventHandler <TimePickerDialogIntervals.TimeSetEventArgs>(UpdateDuration), Element.Time.Hours, Element.Time.Minutes, true); var control = new EditText(this.Context); control.Focusable = false; control.FocusableInTouchMode = false; control.Clickable = false; control.Click += (sender, ea) => timePickerDlg.Show(); control.Text = Element.Time.Hours.ToString("00") + ":" + Element.Time.Minutes.ToString("00"); if (e.OldElement == null) { control.Background = null; var layoutParams1 = new MarginLayoutParams(Control.LayoutParameters); layoutParams1.SetMargins(0, 0, 0, 0); LayoutParameters = layoutParams1; control.LayoutParameters = layoutParams1; control.SetPadding(0, 0, 0, 0); SetPadding(0, 0, 0, 0); } SetNativeControl(control); }
protected override void OnElementChanged(ElementChangedEventArgs <Picker> e) { base.OnElementChanged(e); if (Control != null) { if (e.OldElement == null || e.NewElement != null) { Control.Background = null; var armPicker = e.NewElement as CustomPicker; var layoutParams = new MarginLayoutParams(Control.LayoutParameters); layoutParams.SetMargins(0, 0, 0, 0); LayoutParameters = layoutParams; Control.LayoutParameters = layoutParams; Control.SetPadding(0, 0, 0, 0); SetPadding(0, 0, 0, 0); Control.TextSize *= (armPicker.FontSize * 0.01f); Control.SetHintTextColor(Android.Graphics.Color.ParseColor(armPicker.PlaceholderColor)); //Control.SetHintTextColor(Android.Graphics.Color.ParseColor(armPicker.PlaceholderColor)); //Control.Typeface = Typeface.CreateFromAsset(Context.Assets, "OpenSans-Light.ttf"); } if (Control != null) { Control.Background = null; Element.BackgroundColor = System.Drawing.Color.Transparent; Control.Gravity = GravityFlags.Start; Control.TextSize = 12; } } }
protected override void OnAttached() { try { if (Control is EditText || Control is PickerEditText) { Control.Background = new ColorDrawable(Android.Graphics.Color.Transparent); Control.SetPadding(25, 0, 25, 0); } else if (Control is Android.Widget.DatePicker || Control is Android.Widget.Spinner) { Control.Background = null; var datePicker = Control as Android.Widget.DatePicker; var layoutParams = new MarginLayoutParams(Control.LayoutParameters); layoutParams.SetMargins(0, 0, 0, 0); datePicker.LayoutParameters = layoutParams; Control.LayoutParameters = layoutParams; datePicker.SetPadding(25, 0, 25, 0); } } catch (Exception ex) { Debug.WriteLine("Cannot set property on attached control. Error: {0}", ex.Message); } }
protected override void OnElementChanged(ElementChangedEventArgs <TabbedPage> e) { base.OnElementChanged(e); var metrics = Resources.DisplayMetrics; var width = metrics.WidthPixels; floatingActionButton = new FloatingActionButton(this.Context); var layoutParams = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); LayoutParams paramss = new LayoutParams( LayoutParams.WrapContent, LayoutParams.WrapContent ); MarginLayoutParams marginLayout = new MarginLayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); marginLayout.SetMargins((int)(width / 2.3), 0, 0, 40); floatingActionButton.BackgroundTintList = Context.GetColorStateList(Resource.Color.blueColor); floatingActionButton.Click += FloatingActionButton_Click; floatingActionButton.LayoutParameters = marginLayout; floatingActionButton.SetBackgroundColor(Android.Graphics.Color.Blue); floatingActionButton.SetImageResource(Resource.Drawable.plus_white); floatingActionButton.SetForegroundGravity(GravityFlags.Center); floatingActionButton.Elevation = 6; var layout = (GetChildAt(0) as Android.Widget.RelativeLayout); RelativeLayout.LayoutParams p = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); p.AddRule(LayoutRules.AlignBottom); //layout.AddView(floatingActionButton); var bottomNavigationView = (GetChildAt(0) as Android.Widget.RelativeLayout).GetChildAt(1) as BottomNavigationView; //ViewGroupUtils.removeView(bottomNavigationView); //var b = LayoutInflater.From(this.Context).Inflate(Resource.Layout.MaterialBottomAppBar, null); //layout.AddView(b,1); bottomNavigationView.SetClipChildren(false); var menuView = bottomNavigationView.GetChildAt(0) as BottomNavigationMenuView; BottomNavigationItemView item2 = (BottomNavigationItemView)menuView.GetChildAt(1); BottomNavigationItemView item3 = (BottomNavigationItemView)menuView.GetChildAt(2); item2.SetPadding(0, 0, 100, 0); item3.SetPadding(100, 0, 0, 0); //item2.SetPaddingRelative(0, 0, 300, 0); //for (int i = 0; i < menuView.ChildCount; i++) //{ // BottomNavigationItemView item = (BottomNavigationItemView)menuView.GetChildAt(i); // item.SetPadding(0, 0, 50, 0); // //noinspection RestrictedApi // item.SetShifting(false); // // set once again checked value, so view will be updated // //noinspection RestrictedApi // item.SetChecked(item.ItemData.IsChecked); //} bottomNavigationView.AddView(floatingActionButton); }
protected override void OnElementChanged(ElementChangedEventArgs <Picker> e) { base.OnElementChanged(e); if (e.OldElement == null) { Control.Background = null; var layoutParams = new MarginLayoutParams(Control.LayoutParameters); layoutParams.SetMargins(0, 0, 0, 0); LayoutParameters = layoutParams; } }
void updateBorder() { Control.Background = null; var layoutParams = new MarginLayoutParams(Control.LayoutParameters); layoutParams.SetMargins(0, 0, 0, 0); LayoutParameters = layoutParams; Control.LayoutParameters = layoutParams; Control.SetPadding(0, 0, 0, 0); SetPadding(0, 0, 0, 0); }
protected override void OnElementChanged(ElementChangedEventArgs <Editor> e) { base.OnElementChanged(e); if (e.OldElement == null) { Control.Gravity = GravityFlags.Center; var layoutParams = new MarginLayoutParams(Control.LayoutParameters); layoutParams.SetMargins(0, 0, 0, 0); LayoutParameters = layoutParams; } }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); var newCustomEntryKeyboard = e.NewElement as EntryWithCustomKeyboard; var oldCustomEntryKeyboard = e.OldElement as EntryWithCustomKeyboard; if (newCustomEntryKeyboard == null && oldCustomEntryKeyboard == null) { return; } if (e.NewElement != null) { this.entryWithCustomKeyboard = newCustomEntryKeyboard; this.CreateCustomKeyboard(); this.inputTypeToUse = this.entryWithCustomKeyboard.Keyboard.ToInputType() | InputTypes.TextFlagNoSuggestions; // Here we set the EditText event handlers this.EditText.FocusChange += Control_FocusChange; this.EditText.TextChanged += EditText_TextChanged; this.EditText.Click += EditText_Click; this.EditText.Touch += EditText_Touch; this.EditText.Background = null; var lp = new MarginLayoutParams(Control.LayoutParameters); lp.SetMargins(0, 0, 0, 10); LayoutParameters = lp; Control.LayoutParameters = lp; this.EditText.SetPadding(0, 0, 0, 0); SetPadding(0, 0, 0, 0); } // Dispose control if (e.OldElement != null) { this.EditText.FocusChange -= Control_FocusChange; this.EditText.TextChanged -= EditText_TextChanged; this.EditText.Click -= EditText_Click; this.EditText.Touch -= EditText_Touch; this.EditText.Background = null; var lp = new MarginLayoutParams(Control.LayoutParameters); lp.SetMargins(0, 0, 0, 10); LayoutParameters = lp; Control.LayoutParameters = lp; this.EditText.SetPadding(0, 0, 0, 0); SetPadding(0, 0, 0, 0); } }
/// <summary> /// Change entry properties here /// </summary> /// <param name="e"></param> protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (Control != null) { Control.SetBackgroundColor(global::Android.Graphics.Color.Transparent); var layoutParams = new MarginLayoutParams(Control.LayoutParameters); layoutParams.SetMargins(0, 0, 0, 0); LayoutParameters = layoutParams; Control.LayoutParameters = layoutParams; Control.TextAlignment = Android.Views.TextAlignment.Gravity; } }
protected override void OnElementChanged(ElementChangedEventArgs <TimePicker> e) { base.OnElementChanged(e); if (e.OldElement == null) { Control.SetBackgroundResource(Resource.Layout.rounded_shape); var layoutParams = new MarginLayoutParams(Control.LayoutParameters); layoutParams.SetMargins(0, 0, 0, 0); LayoutParameters = layoutParams; Control.LayoutParameters = layoutParams; Control.SetPadding(0, 0, 0, 0); SetPadding(0, 0, 0, 0); } }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (e.OldElement == null) { Control.Background = null; var lp = new MarginLayoutParams(Control.LayoutParameters); lp.SetMargins(0, 0, 0, 0); LayoutParameters = lp; Control.LayoutParameters = lp; Control.SetPadding(0, 0, 0, 0); SetPadding(0, 0, 0, 0); } }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.TimePicker> e) { base.OnElementChanged(e); if (e.OldElement == null) { Control.Background = null; var layoutParams = new MarginLayoutParams(Control.LayoutParameters); layoutParams.SetMargins(0, 0, 0, 0); LayoutParameters = layoutParams; Control.LayoutParameters = layoutParams; Control.SetPadding(15, 15, 15, 15); SetPadding(0, 0, 0, 0); } }
protected override void OnElementChanged(ElementChangedEventArgs <Picker> e) { base.OnElementChanged(e); if (e.OldElement == null) { Control.Background = null; Control.SetTextSize(Android.Util.ComplexUnitType.Dip, (float)e.NewElement.FontSize); var layoutParams = new MarginLayoutParams(Control.LayoutParameters); layoutParams.SetMargins(0, 0, 0, 0); LayoutParameters = layoutParams; Control.LayoutParameters = layoutParams; Control.SetPadding(0, 0, 0, 0); SetPadding(0, 0, 0, 0); } }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (e.OldElement == null) { Control.Background = null; var layoutParams = new MarginLayoutParams(Control.LayoutParameters); layoutParams.SetMargins(0, 0, 0, 0); LayoutParameters = layoutParams; Control.LayoutParameters = layoutParams; Control.SetPadding(0, 0, 0, 0); Control.Gravity = Android.Views.GravityFlags.CenterVertical; SetPadding(0, 0, 0, 0); } }
protected override void OnElementChanged(ElementChangedEventArgs <DatePicker> e) { base.OnElementChanged(e); if (e.OldElement == null) { Control.Background = null; var layoutParams = new MarginLayoutParams(Control.LayoutParameters); layoutParams.SetMargins(0, 0, 0, 0); LayoutParameters = layoutParams; GradientDrawable gd = new GradientDrawable(); gd.SetStroke(0, Android.Graphics.Color.Transparent); Control.SetBackgroundDrawable(gd); Control.LayoutParameters = layoutParams; } }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (e.OldElement == null) { Control.Background = null; var layoutParams = new MarginLayoutParams(Control.LayoutParameters); layoutParams.SetMargins(0, 0, 0, 0); LayoutParameters = layoutParams; Control.LayoutParameters = layoutParams; Control.SetPadding(0, 0, 0, 0); Control.SetBackgroundColor(Color.Transparent.ToAndroid()); SetPadding(0, 0, 0, 0); } }
private void SetControl() { if (Control == null) { return; } Control.Background = new ColorDrawable(Color.Transparent.ToAndroid()); Control.SetPadding(0, 0, 0, 0); Control.SetIncludeFontPadding(false); Control.SetMinimumHeight((int)MaterialHelper.ConvertToDp(20)); var layoutParams = new MarginLayoutParams(Control.LayoutParameters); layoutParams.SetMargins(0, 0, 0, 0); Control.LayoutParameters = layoutParams; }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (e.OldElement == null) { Control.Background = null; var layoutParams = new MarginLayoutParams(Control.LayoutParameters); layoutParams.SetMargins(0, 0, 0, 0); LayoutParameters = layoutParams; Control.LayoutParameters = layoutParams; Control.SetPadding(0, 0, 0, 0); SetPadding(0, 0, 0, 0); //var item= Resource.Layout.Layout; } }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (e == null) { return; } Control.SetBackgroundColor(Android.Graphics.Color.Transparent); using (var layoutParams = new MarginLayoutParams(Control.LayoutParameters)) { layoutParams.SetMargins(0, 0, 0, 0); Control.LayoutParameters = layoutParams; Control.SetPadding(Control.Left, 0, Control.Right, 0); } }
private void SetBorder(BorderlessEntry view) { if (view == null || Control == null) { return; } if (!view.HasBorder) { Control.Background = null; var layoutParams = new MarginLayoutParams(Control.LayoutParameters); layoutParams.SetMargins(0, 0, 0, 0); LayoutParameters = layoutParams; Control.LayoutParameters = layoutParams; Control.SetPadding(0, 0, 0, 0); SetPadding(0, 0, 0, 0); } }
protected override void OnElementChanged(ElementChangedEventArgs <Picker> e) { base.OnElementChanged(e); if (e.OldElement == null) { Control.Background = null; } if (Control != null) { // stop double triggering Control.Focusable = false; Control.FocusableInTouchMode = false; } var layoutParams = new MarginLayoutParams(Control.LayoutParameters); layoutParams.SetMargins(0, 0, 0, 0); LayoutParameters = layoutParams; Control.LayoutParameters = layoutParams; Control.SetPadding(0, 0, 0, 0); SetPadding(0, 0, 0, 0); try { if (!string.IsNullOrEmpty(e.NewElement?.FontFamily)) { var font = Typeface.CreateFromAsset(Android.App.Application.Context.ApplicationContext.Assets, e.NewElement.FontFamily + ".ttf"); Control.Typeface = font; //if (e.NewElement?.FontFamily == "Raleway-ExtraBold") //{ // var font = Typeface.CreateFromAsset(Android.App.Application.Context.ApplicationContext.Assets, // e.NewElement.FontFamily + ".ttf"); // Control.Typeface = font; //} //else //{ // var font = Typeface.CreateFromAsset(Android.App.Application.Context.ApplicationContext.Assets, e.NewElement.FontFamily + ".otf"); // Control.Typeface = font; //} } } catch (System.Exception) { } }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.DatePicker> args) { base.OnElementChanged(args); if (args.OldElement == null) { Control.Background = null; var layoutParams = new MarginLayoutParams(Control.LayoutParameters); layoutParams.SetMargins(0, 0, 0, 0); LayoutParameters = layoutParams; GradientDrawable gd = new GradientDrawable(); gd.SetStroke(0, Android.Graphics.Color.LightGray); Control.SetBackgroundDrawable(gd); Control.LayoutParameters = layoutParams; Control.SetPadding(0, 0, 0, 0); SetPadding(0, 0, 0, 0); } }
protected override void OnElementChanged(ElementChangedEventArgs <DatePicker> e) { base.OnElementChanged(e); if (e.OldElement == null) { Control.Background = null; var lp = new MarginLayoutParams(Control.LayoutParameters); lp.SetMargins(0, 0, 0, 0); LayoutParameters = lp; Control.LayoutParameters = lp; Control.SetPadding(0, 0, 0, 0); SetPadding(0, 0, 0, 0); this.Control.TextAlignment = Android.Views.TextAlignment.ViewEnd; } }
protected override void OnElementChanged(ElementChangedEventArgs <Picker> e) { base.OnElementChanged(e); if (e.OldElement == null) { //Control.Background = Context.GetDrawable("downarrow"); Control.Background = GetLayeredBg(); Control.Gravity = GravityFlags.Center; var layoutParams = new MarginLayoutParams(Control.LayoutParameters); layoutParams.SetMargins(0, 0, 0, 0); LayoutParameters = layoutParams; Control.LayoutParameters = layoutParams; Control.SetPadding(16, 8, 52, 8); SetPadding(0, 0, 0, 0); } }
protected override void OnElementChanged(ElementChangedEventArgs <Editor> e) { base.OnElementChanged(e); if (Control == null || e.OldElement != null || this.Element == null) { return; } if (e.OldElement == null) { Control.Background = null; var layoutParams = new MarginLayoutParams(Control.LayoutParameters); layoutParams.SetMargins(0, 0, 0, 0); LayoutParameters = layoutParams; Control.LayoutParameters = layoutParams; Control.SetPadding(0, 0, 0, 0); SetPadding(0, 0, 0, 0); } }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (e.OldElement == null) { Control.Background = null; var lp = new MarginLayoutParams(Control.LayoutParameters); lp.SetMargins(0, 0, 0, 10); LayoutParameters = lp; Control.LayoutParameters = lp; Control.SetPadding(0, 0, 0, 0); SetPadding(0, 0, 0, 0); IntPtr IntPtrtextViewClass = JNIEnv.FindClass(typeof(TextView)); IntPtr mCursorDrawableResProperty = JNIEnv.GetFieldID(IntPtrtextViewClass, "mCursorDrawableRes", "I"); JNIEnv.SetField(Control.Handle, mCursorDrawableResProperty, 0); } }
protected override void OnElementChanged(ElementChangedEventArgs <Picker> e) { base.OnElementChanged(e); var picker = e.NewElement; if (Control != null) { var layoutParams = new MarginLayoutParams(Control.LayoutParameters); layoutParams.SetMargins(0, 0, 0, 0); Control.LayoutParameters = layoutParams; Control.SetPadding(0, 0, 0, 0); SetPadding(0, 0, 0, 0); // Remove borders GradientDrawable gd = new GradientDrawable(); gd.SetStroke(0, Android.Graphics.Color.LightGray); Control.SetBackgroundDrawable(gd); } }