Пример #1
0
        private void InitView(Context context, IAttributeSet attrs, int defStyleAttr, int defStyleRes)
        {
            if (IsInEditMode)
            {
                return;
            }
            else
            {
                View view = LayoutInflater.From(context).Inflate(Resource.Layout.view_carousel, this, true);
                this._containerViewPager = (CarouselViewPager)view.FindViewById(Resource.Id.containerViewPager);
                this._mIndicator         = (CirclePageIndicator)view.FindViewById(Resource.Id.indicator);
                this._containerViewPager.AddOnPageChangeListener(new CarouselViewOnPageChangeListener(this));
                // Retrieve styles attributes
                TypedArray a = context.ObtainStyledAttributes(attrs, Resource.Styleable.CarouselView, defStyleAttr, 0);
                try
                {
                    SetIndicatorMarginVertical(a.GetInt(Resource.Styleable.CarouselView_indicatorMarginVertical,
                                                        Resources.GetDimensionPixelSize(Resource.Dimension.default_indicator_margin_vertical)));
                    SetIndicatorMarginHorizontal(a.GetInt(Resource.Styleable.CarouselView_indicatorMarginHorizontal,
                                                          Resources.GetDimensionPixelSize(Resource.Dimension.default_indicator_margin_horizontal)));
                    this.SetPageTransformInterval(a.GetInt(Resource.Styleable.CarouselView_pageTransformInterval,
                                                           _defaultSlideVelocity));
                    this.SetSlideInterval(a.GetInt(Resource.Styleable.CarouselView_slideInterval, _defaultSlideInterval));
                    SetOrientation(a.GetInt(Resource.Styleable.CarouselView_indicatorOrientation,
                                            (int)Android.Widget.Orientation.Horizontal));
                    SetIndicatorGravity((GravityFlags)a.GetInt(Resource.Styleable.CarouselView_indicatorGravity, (int)(GravityFlags.Bottom | GravityFlags.CenterHorizontal)));
                    SetAutoPlay(a.GetBoolean(Resource.Styleable.CarouselView_autoPlay, true));
                    SetDisableAutoPlayOnUserInteraction(
                        a.GetBoolean(Resource.Styleable.CarouselView_disableAutoPlayOnUserInteraction, false));
                    SetAnimateOnBoundary(a.GetBoolean(Resource.Styleable.CarouselView_animateOnBoundary, true));
                    this.SetPageTransformer(new CarouselViewPagerTransformer((CarouselViewPagerTransformerType)a.GetInt(Resource.Styleable.CarouselView_pageTransformer, (int)CarouselViewPagerTransformerType.Default)));
                    Color fillColor = a.GetColor(Resource.Styleable.CarouselView_fillColor, 0);
                    if (fillColor != 0)
                    {
                        SetFillColor(fillColor);
                    }

                    Color pageColor = a.GetColor(Resource.Styleable.CarouselView_pageColor, 0);
                    if (pageColor != 0)
                    {
                        SetPageColor(pageColor);
                    }

                    float radius = a.GetDimensionPixelSize(Resource.Styleable.CarouselView_radius, 0);
                    if (radius != 0)
                    {
                        SetRadius(radius);
                    }

                    SetSnap(a.GetBoolean(Resource.Styleable.CarouselView_snap,
                                         Resources.GetBoolean(Resource.Boolean.default_circle_indicator_snap)));
                    Color strokeColor = a.GetColor(Resource.Styleable.CarouselView_strokeColor, 0);
                    if (strokeColor != 0)
                    {
                        SetStrokeColor(strokeColor);
                    }

                    float strokeWidth = a.GetDimensionPixelSize(Resource.Styleable.CarouselView_strokeWidth, 0);
                    if (strokeWidth != 0)
                    {
                        SetStrokeWidth(strokeWidth);
                    }
                }
                finally
                {
                    a.Recycle();
                }
            }
        }
Пример #2
0
 public SwipeTask(CarouselView carouselView, CarouselViewPager containerViewPager)
 {
     _carouselView       = carouselView;
     _containerViewPager = containerViewPager;
 }