public SetPageColor ( Android.Graphics.Color pageColor ) : void | ||
pageColor | Android.Graphics.Color | |
return | void |
void SetIndicators() { if (Element.ShowIndicators) { SetPosition(); indicators.SetViewPager(viewPager); // IndicatorsTintColor BP indicators.SetFillColor(Element.IndicatorsTintColor.ToAndroid()); // CurrentPageIndicatorTintColor BP indicators.SetPageColor(Element.CurrentPageIndicatorTintColor.ToAndroid()); // IndicatorsShape BP indicators.SetStyle(Element.IndicatorsShape); // Rounded or Squared } else { indicators.RemoveAllViews(); } // ShowIndicators BP indicators.Visibility = Element.ShowIndicators ? AViews.ViewStates.Visible : AViews.ViewStates.Gone; }
void SetIndicators() { if (Element.ShowIndicators) { SetPosition(); indicators.SetViewPager(viewPager); // IndicatorsTintColor BP indicators.SetFillColor(Element.IndicatorsTintColor.ToAndroid()); // CurrentPageIndicatorTintColor BP indicators.SetPageColor(Element.CurrentPageIndicatorTintColor.ToAndroid()); // IndicatorsShape BP indicators.SetStyle(Element.IndicatorsShape); // Rounded or Squared var layoutParams = new global::Android.Widget.RelativeLayout.LayoutParams(global::Android.Widget.RelativeLayout.LayoutParams.MatchParent, global::Android.Widget.RelativeLayout.LayoutParams.WrapContent); layoutParams.AddRule(Element.IndicatorLocation == IndicatorLocation.Top ? global::Android.Widget.LayoutRules.AlignParentTop : global::Android.Widget.LayoutRules.AlignParentBottom); indicators.LayoutParameters = layoutParams; } else { indicators.RemoveAllViews(); } // ShowIndicators BP indicators.Visibility = Element.ShowIndicators? AViews.ViewStates.Visible : AViews.ViewStates.Gone; }
void SetNativeView() { var inflater = AViews.LayoutInflater.From(Forms.Context); // Orientation BP if (Element.Orientation == CarouselViewOrientation.Horizontal) { nativeView = inflater.Inflate(Resource.Layout.horizontal_viewpager, null); } else { nativeView = inflater.Inflate(Resource.Layout.vertical_viewpager, null); } viewPager = nativeView.FindViewById <ViewPager>(Resource.Id.pager); viewPager.Adapter = new PageAdapter(Element); viewPager.SetCurrentItem(Element.Position, false); // InterPageSpacing BP var metrics = Resources.DisplayMetrics; var interPageSpacing = Element.InterPageSpacing * metrics.Density; viewPager.PageMargin = (int)interPageSpacing; // InterPageSpacingColor BP viewPager.SetBackgroundColor(Element.InterPageSpacingColor.ToAndroid()); // IsSwipingEnabled BP SetIsSwipingEnabled(); // INDICATORS indicators = nativeView.FindViewById <CirclePageIndicator>(Resource.Id.indicator); SetPosition(); indicators.SetViewPager(viewPager); // IndicatorsTintColor BP indicators.SetFillColor(Element.IndicatorsTintColor.ToAndroid()); // CurrentPageIndicatorTintColor BP indicators.SetPageColor(Element.CurrentPageIndicatorTintColor.ToAndroid()); // IndicatorsShape BP indicators.SetStyle(Element.IndicatorsShape); // Rounded or Squared // ShowIndicators BP indicators.Visibility = Element.ShowIndicators ? AViews.ViewStates.Visible : AViews.ViewStates.Gone; viewPager.PageSelected += ViewPager_PageSelected; viewPager.PageScrollStateChanged += ViewPager_PageScrollStateChanged; SetNativeControl(nativeView); }
protected override void OnElementChanged(ElementChangedEventArgs <CarouselViewControl> e) { base.OnElementChanged(e); if (Control == null) { // Instantiate the native control and assign it to the Control property with // the SetNativeControl method var inflater = AViews.LayoutInflater.From(Forms.Context); if (Element.Orientation == Orientation.Horizontal) { nativeView = inflater.Inflate(Resource.Layout.viewpager, null); } else { nativeView = inflater.Inflate(Resource.Layout.vertical_viewpager, null); } var metrics = Resources.DisplayMetrics; var interPageSpacing = Element.InterPageSpacing * metrics.Density; viewPager = nativeView.FindViewById <ViewPager>(Resource.Id.pager); viewPager.PageMargin = (int)interPageSpacing; indicator = nativeView.FindViewById <CirclePageIndicator>(Resource.Id.indicator); indicator.SetViewPager(viewPager); indicator.SetPageColor(Element.PageIndicatorTintColor.ToAndroid()); indicator.SetFillColor(Element.CurrentPageIndicatorTintColor.ToAndroid()); indicator.Visibility = Element.ShowIndicators ? AViews.ViewStates.Visible : AViews.ViewStates.Gone; SetNativeControl(nativeView); } if (e.OldElement != null) { // Unsubscribe from event handlers and cleanup any resources if (viewPager != null) { viewPager.PageSelected -= ViewPager_PageSelected; viewPager.PageScrollStateChanged -= ViewPager_PageScrollStateChanged; } if (Element != null) { Element.RemoveAction = null; Element.InsertAction = null; Element.SetCurrentAction = null; } } if (e.NewElement != null) { // Configure the control and subscribe to event handlers viewPager.PageSelected += ViewPager_PageSelected; viewPager.PageScrollStateChanged += ViewPager_PageScrollStateChanged; Element.RemoveAction = new Action <int>(RemoveItem); Element.InsertAction = new Action <object, int>(InsertItem); Element.SetCurrentAction = new Action <int>(SetCurrentItem); } }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); if (Element == null || viewPager == null) { return; } var rect = this.Element.Bounds; switch (e.PropertyName) { case "Orientation": orientationChanged = true; SetNativeView(); Element.SendPositionSelected(); Element.PositionSelectedCommand?.Execute(null); break; case "BackgroundColor": viewPager.SetBackgroundColor(Element.BackgroundColor.ToAndroid()); break; case "IsSwipeEnabled": SetIsSwipeEnabled(); break; case "IndicatorsTintColor": indicators?.SetFillColor(Element.IndicatorsTintColor.ToAndroid()); break; case "CurrentPageIndicatorTintColor": indicators?.SetPageColor(Element.CurrentPageIndicatorTintColor.ToAndroid()); break; case "IndicatorsShape": indicators?.SetStyle((int)Element.IndicatorsShape); break; case "ShowIndicators": SetIndicators(); break; case "ItemsSource": SetPosition(); viewPager.Adapter = new PageAdapter(Element); viewPager.SetCurrentItem(Element.Position, false); SetArrowsVisibility(); indicators?.SetViewPager(viewPager); Element.SendPositionSelected(); Element.PositionSelectedCommand?.Execute(null); if (Element.ItemsSource != null && Element.ItemsSource is INotifyCollectionChanged) { ((INotifyCollectionChanged)Element.ItemsSource).CollectionChanged += ItemsSource_CollectionChanged; } break; case "ItemTemplate": viewPager.Adapter = new PageAdapter(Element); viewPager.SetCurrentItem(Element.Position, false); indicators?.SetViewPager(viewPager); Element.SendPositionSelected(); Element.PositionSelectedCommand?.Execute(null); break; case "Position": if (!isChangingPosition) { SetCurrentPage(Element.Position); } break; case "ShowArrows": SetArrows(); break; case "ArrowsBackgroundColor": if (prevBtn == null || nextBtn == null) { return; } prevBtn.SetBackgroundColor(Element.ArrowsBackgroundColor.ToAndroid()); nextBtn.SetBackgroundColor(Element.ArrowsBackgroundColor.ToAndroid()); break; case "ArrowsTintColor": var prevArrow = nativeView.FindViewById <AWidget.ImageView>(Resource.Id.prevArrow); prevArrow.SetColorFilter(Element.ArrowsTintColor.ToAndroid()); var nextArrow = nativeView.FindViewById <AWidget.ImageView>(Resource.Id.nextArrow); nextArrow.SetColorFilter(Element.ArrowsTintColor.ToAndroid()); break; case "ArrowsTransparency": if (prevBtn == null || nextBtn == null) { return; } prevBtn.Alpha = Element.ArrowsTransparency; nextBtn.Alpha = Element.ArrowsTransparency; break; } }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); var rect = this.Element.Bounds; switch (e.PropertyName) { case "Orientation": if (Element != null) { orientationChanged = true; SetNativeView(); Element.PositionSelected?.Invoke(Element, Element.Position); } break; case "InterPageSpacing": //var metrics = Resources.DisplayMetrics; //var interPageSpacing = Element.InterPageSpacing * metrics.Density; //viewPager.PageMargin = (int)interPageSpacing; break; case "BackgroundColor": viewPager?.SetBackgroundColor(Element.BackgroundColor.ToAndroid()); break; case "IsSwipingEnabled": SetIsSwipingEnabled(); break; case "IndicatorsTintColor": indicators?.SetFillColor(Element.IndicatorsTintColor.ToAndroid()); break; case "CurrentPageIndicatorTintColor": indicators?.SetPageColor(Element.CurrentPageIndicatorTintColor.ToAndroid()); break; case "IndicatorsShape": indicators?.SetStyle(Element.IndicatorsShape); break; case "ShowIndicators": SetIndicators(); break; case "ItemsSource": if (Element != null && viewPager != null) { SetPosition(); viewPager.Adapter = new PageAdapter(Element); viewPager.SetCurrentItem(Element.Position, false); indicators?.SetViewPager(viewPager); Element.PositionSelected?.Invoke(Element, Element.Position); if (Element.ItemsSource != null && Element.ItemsSource is INotifyCollectionChanged) { ((INotifyCollectionChanged)Element.ItemsSource).CollectionChanged += ItemsSource_CollectionChanged; } } break; case "ItemTemplate": if (Element != null && viewPager != null) { viewPager.Adapter = new PageAdapter(Element); viewPager.SetCurrentItem(Element.Position, false); indicators?.SetViewPager(viewPager); Element.PositionSelected?.Invoke(Element, Element.Position); } break; case "Position": if (Element != null && !isSwiping) { SetCurrentPage(Element.Position); } break; } }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); var rect = this.Element.Bounds; switch (e.PropertyName) { case "Renderer": // Fix for NullReferenceException on Android tabbed page #59 if (!Element.Height.Equals(-1)) { SetNativeView(); Element.PositionSelected?.Invoke(Element, EventArgs.Empty); } break; case "Width": //ElementWidth = rect.Width; break; case "Height": // To avoid calling ConfigureViewPager twice on launch; if (ElementHeight.Equals(0)) { ElementHeight = rect.Height; SetNativeView(); Element.PositionSelected?.Invoke(Element, EventArgs.Empty); } break; case "Orientation": SetNativeView(); Element.PositionSelected?.Invoke(Element, EventArgs.Empty); break; case "InterPageSpacing": //var metrics = Resources.DisplayMetrics; //var interPageSpacing = Element.InterPageSpacing * metrics.Density; //viewPager.PageMargin = (int)interPageSpacing; break; case "InterPageSpacingColor": viewPager?.SetBackgroundColor(Element.InterPageSpacingColor.ToAndroid()); break; case "IsSwipingEnabled": SetIsSwipingEnabled(); break; case "IndicatorsTintColor": indicators?.SetFillColor(Element.IndicatorsTintColor.ToAndroid()); break; case "CurrentPageIndicatorTintColor": indicators?.SetPageColor(Element.CurrentPageIndicatorTintColor.ToAndroid()); break; case "IndicatorsShape": indicators?.SetStyle(Element.IndicatorsShape); break; case "ShowIndicators": if (indicators != null) { indicators.Visibility = Element.ShowIndicators ? AViews.ViewStates.Visible : AViews.ViewStates.Gone; } break; case "ItemsSource": if (viewPager != null) { SetPosition(); viewPager.Adapter = new PageAdapter(Element); viewPager.SetCurrentItem(Element.Position, false); indicators?.SetViewPager(viewPager); Element.PositionSelected?.Invoke(Element, EventArgs.Empty); if (Element.ItemsSource != null && Element.ItemsSource is INotifyCollectionChanged) { ((INotifyCollectionChanged)Element.ItemsSource).CollectionChanged += ItemsSource_CollectionChanged; } } break; case "ItemTemplate": if (viewPager != null) { viewPager.Adapter = new PageAdapter(Element); viewPager.SetCurrentItem(Element.Position, false); indicators?.SetViewPager(viewPager); Element.PositionSelected?.Invoke(Element, EventArgs.Empty); } break; case "Position": if (!isSwiping) { SetCurrentPage(Element.Position); } break; } }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); var rect = this.Element.Bounds; switch (e.PropertyName) { case "Orientation": if (Element != null) { orientationChanged = true; SetNativeView(); Element.SendPositionSelected(); Element.PositionSelectedCommand?.Execute(null); } break; case "InterPageSpacing": //var metrics = Resources.DisplayMetrics; //var interPageSpacing = Element.InterPageSpacing * metrics.Density; //viewPager.PageMargin = (int)interPageSpacing; break; case "BackgroundColor": viewPager?.SetBackgroundColor(Element.BackgroundColor.ToAndroid()); break; case "IsSwipingEnabled": SetIsSwipingEnabled(); break; case "IndicatorsTintColor": indicators?.SetFillColor(Element.IndicatorsTintColor.ToAndroid()); break; case "CurrentPageIndicatorTintColor": indicators?.SetPageColor(Element.CurrentPageIndicatorTintColor.ToAndroid()); break; case "IndicatorsShape": indicators?.SetStyle(Element.IndicatorsShape); break; case "ShowIndicators": SetIndicators(); break; case "ItemsSource": if (Element != null && viewPager != null) { SetPosition(); viewPager.Adapter = new PageAdapter(Element); viewPager.SetCurrentItem(Element.Position, false); indicators?.SetViewPager(viewPager); Element.SendPositionSelected(); Element.PositionSelectedCommand?.Execute(null); if (Element.ItemsSource != null && Element.ItemsSource is INotifyCollectionChanged) { ((INotifyCollectionChanged)Element.ItemsSource).CollectionChanged += ItemsSource_CollectionChanged; } } break; case "ItemTemplate": if (Element != null && viewPager != null) { viewPager.Adapter = new PageAdapter(Element); viewPager.SetCurrentItem(Element.Position, false); indicators?.SetViewPager(viewPager); Element.SendPositionSelected(); Element.PositionSelectedCommand?.Execute(null); } break; case "Position": if (Element != null && !isSwiping) { if (prevBtn != null) { prevBtn.Visibility = Element.Position == 0 ? AViews.ViewStates.Gone : AViews.ViewStates.Visible; } if (nextBtn != null) { nextBtn.Visibility = Element.Position == Element.ItemsSource.GetCount() - 1 ? AViews.ViewStates.Gone : AViews.ViewStates.Visible; } SetCurrentPage(Element.Position); } break; case "ShowArrows": SetArrows(); break; case "ArrowsBackgroundColor": if (prevBtn != null && nextBtn != null) { prevBtn.SetBackgroundColor(Element.ArrowsBackgroundColor.ToAndroid()); nextBtn.SetBackgroundColor(Element.ArrowsBackgroundColor.ToAndroid()); } break; case "ArrowsTintColor": if (prevBtn != null && nextBtn != null) { var prevArrow = nativeView.FindViewById <AWidget.ImageView>(Resource.Id.prevArrow); prevArrow.SetColorFilter(Element.ArrowsTintColor.ToAndroid()); var nextArrow = nativeView.FindViewById <AWidget.ImageView>(Resource.Id.nextArrow); nextArrow.SetColorFilter(Element.ArrowsTintColor.ToAndroid()); } break; } }