public StyleListItem() { BorderWidth = 1; BorderColor = Colors.CartoNavyLight; Elevated = true; BackgroundColor = StyleListView.Background; label = new Label(); label.VerticalTextAlignment = TextAlignment.Center; label.TextColor = Colors.CartoNavy; label.FontSize = 13; label.FontAttributes = FontAttributes.None; MapView = new MapContainer(); #if __IOS__ MapView.UserInteractionEnabled = false; #else overlay = new ClickView(); overlay.Click += delegate { Click(this, EventArgs.Empty); }; #endif }
protected override void OnElementChanged(ElementChangedEventArgs <RelativeLayout> e) { base.OnElementChanged(e); if (e.NewElement != null) { View = e.NewElement as ClickView; #if __ANDROID__ SetBackgroundColor(View.BackgroundColor.ToNativeColor()); Touch += (object sender, TouchEventArgs args) => { if (!View.IsEnabled) { return; } var action = args.Event.Action; if (action == Android.Views.MotionEventActions.Down) { Alpha = 0.5f; } else if (action == Android.Views.MotionEventActions.Up) { Alpha = 1.0f; View.Click?.Invoke(View, EventArgs.Empty); } else if (action == Android.Views.MotionEventActions.Cancel) { Alpha = 1.0f; } }; #else BackgroundColor = View.BackgroundColor.ToNativeColor(); #endif } }
public TestView() { Content = new ClickView(); Content.BackgroundColor = Colors.CartoGreen; }