public AnimatedPathView(Context context, IAttributeSet attrs, int defStyle)
            : base(context, attrs, defStyle)
        {
            mStrokePaint.SetStyle(Paint.Style.Stroke);
            mFillPaint.SetStyle(Paint.Style.Fill);

            TypedArray a = context.ObtainStyledAttributes(attrs, Resource.Styleable.AnimatedPathView, defStyle, 0);

            try {
                if (a != null)
                {
                    mStrokePaint.StrokeWidth = a.GetDimensionPixelSize(Resource.Styleable.AnimatedPathView_strokeWidth, 1);
                    mStrokePaint.Color       = a.GetColor(Resource.Styleable.AnimatedPathView_strokeColor, unchecked ((int)0xff000000));
                    svg = new SvgHelper(mStrokePaint);
                    mFillPaint.Color = a.GetColor(Resource.Styleable.AnimatedPathView_fillColor, unchecked ((int)0xff000000));
                    phase            = a.GetFloat(Resource.Styleable.AnimatedPathView_phase, 0.0f);
                    duration         = a.GetInt(Resource.Styleable.AnimatedPathView_duration, 4000);
                    fillDuration     = a.GetInt(Resource.Styleable.AnimatedPathView_fillDuration, 4000);
                    fillOffset       = a.GetInt(Resource.Styleable.AnimatedPathView_fillOffset, 2000);
                    fadeFactor       = a.GetFloat(Resource.Styleable.AnimatedPathView_fadeFactor, 10.0f);
                    svgResource      = a.GetResourceId(Resource.Styleable.AnimatedPathView_svgPath, 0);
                }
            } finally {
                if (a != null)
                {
                    a.Recycle();
                }
            }
        }
Exemplo n.º 2
0
        private void Init(Context context, IAttributeSet attrs)
        {
            anim = new CircleBarAnim(this);

            defaultSize = DpOrPxUtils.dip2px(context, 100);
            barWidth    = DpOrPxUtils.dip2px(context, 10);

            TypedArray typedArray = context.ObtainStyledAttributes(attrs, Resource.Styleable.CircleBarView);

            progressColor = typedArray.GetColor(Resource.Styleable.CircleBarView_progress_color, Color.Green);                    //默认为绿色
            bgColor       = typedArray.GetColor(Resource.Styleable.CircleBarView_bg_color, Color.Gray);                           //默认为灰色
            startAngle    = typedArray.GetFloat(Resource.Styleable.CircleBarView_start_angle, 0);                                 //默认为0
            sweepAngle    = typedArray.GetFloat(Resource.Styleable.CircleBarView_sweep_angle, 360);                               //默认为360
            barWidth      = typedArray.GetDimension(Resource.Styleable.CircleBarView_bar_width, DpOrPxUtils.dip2px(context, 10)); //默认为10dp
            typedArray.Recycle();                                                                                                 //typedArray用完之后需要回收,防止内存泄漏


            progressPaint           = new Paint();
            progressPaint.StrokeCap = Paint.Cap.Round;
            progressPaint.SetStyle(Paint.Style.Stroke); //只描边,不填充
            progressPaint.Color       = progressColor;
            progressPaint.AntiAlias   = true;           //设置抗锯齿
            progressPaint.StrokeWidth = barWidth;       //随便设置一个画笔宽度,看看效果就好,之后会通过attr自定义属性进行设置

            bgPaint           = new Paint();
            bgPaint.StrokeCap = Paint.Cap.Round;
            bgPaint.SetStyle(Paint.Style.Stroke); //只描边,不填充
            bgPaint.Color       = bgColor;
            bgPaint.AntiAlias   = true;           //设置抗锯齿
            bgPaint.StrokeWidth = barWidth;

            NowProgressNum = 0;
            progressNum    = 0;
            maxNum         = 100;//也是随便设的
        }
        public void InitButton(Context context, IAttributeSet attrs)
        {
            Activity activityCaller = context as Activity;

            if (activityCaller != null)
            {
                Init((Activity)context);
            }

            TypedArray a = context.ObtainStyledAttributes(attrs, Resource.Styleable.ShineButton);

            btnColor         = a.GetColor(Resource.Styleable.ShineButton_btn_color, Color.Gray);
            ButtonFillColour = a.GetColor(Resource.Styleable.ShineButton_btn_fill_color, Color.Black);

            shineParams.UseRandomColor        = a.GetBoolean(Resource.Styleable.ShineButton_allow_random_color, false);
            shineParams.AnimDuration          = a.GetInteger(Resource.Styleable.ShineButton_shine_animation_duration, (int)shineParams.AnimDuration);
            shineParams.BigShineColor         = a.GetColor(Resource.Styleable.ShineButton_big_shine_color, shineParams.BigShineColor);
            shineParams.ClickAnimDuration     = a.GetInteger(Resource.Styleable.ShineButton_click_animation_duration, (int)shineParams.ClickAnimDuration);
            shineParams.EnableFlashing        = a.GetBoolean(Resource.Styleable.ShineButton_enable_flashing, false);
            shineParams.ShineCount            = a.GetInteger(Resource.Styleable.ShineButton_shine_count, shineParams.ShineCount);
            shineParams.ShineDistanceMultiple = a.GetFloat(Resource.Styleable.ShineButton_shine_distance_multiple, shineParams.ShineDistanceMultiple);
            shineParams.ShineTurnAngle        = a.GetFloat(Resource.Styleable.ShineButton_shine_turn_angle, shineParams.ShineTurnAngle);
            shineParams.SmallShineColor       = a.GetColor(Resource.Styleable.ShineButton_small_shine_color, shineParams.SmallShineColor);
            shineParams.SmallShineOffsetAngle = a.GetFloat(Resource.Styleable.ShineButton_small_shine_offset_angle, shineParams.SmallShineOffsetAngle);
            shineParams.ShineSize             = a.GetDimensionPixelSize(Resource.Styleable.ShineButton_shine_size, shineParams.ShineSize);

            a.Recycle();

            SourceColour = btnColor;
        }
        /**
         * Instantiates a new holo circular progress bar.
         *
         * @param context  the context
         * @param attrs    the attrs
         * @param defStyle the def style
         */
        public HoloCircularProgressBar(Context context, IAttributeSet Attrs, int DefStyle) : base(context, Attrs, DefStyle)
        {
            // load the styled attributes and set their properties
            TypedArray attributes = context.ObtainStyledAttributes(Attrs, Resource.Styleable.HoloCircularProgressBar, DefStyle, 0);

            if (attributes != null)
            {
                try {
                    SetProgressColor(attributes.GetColor(Resource.Styleable.HoloCircularProgressBar_progress_color, Color.Cyan));
                    SetProgressBackgroundColor(attributes.GetColor(Resource.Styleable.HoloCircularProgressBar_progress_background_color, Color.Green));
                    SetProgress(attributes.GetFloat(Resource.Styleable.HoloCircularProgressBar_progress, 0.0f));
                    SetMarkerProgress(attributes.GetFloat(Resource.Styleable.HoloCircularProgressBar_marker_progress, 0.0f));
                    SetWheelSize((int)attributes.GetDimension(Resource.Styleable.HoloCircularProgressBar_stroke_width, 10));
                    SetThumbEnabled(attributes.GetBoolean(Resource.Styleable.HoloCircularProgressBar_thumb_visible, true));
                    SetMarkerEnabled(attributes.GetBoolean(Resource.Styleable.HoloCircularProgressBar_marker_visible, true));

                    _gravity = (GravityFlags)attributes.GetInt(Resource.Styleable.HoloCircularProgressBar_android_gravity, (int)GravityFlags.Center);
                } finally {
                    // make sure recycle is always called.
                    attributes.Recycle();
                }
            }

            _thumbRadius = _circleStrokeWidth * 2;

            UpdateBackgroundColor();

            UpdateMarkerColor();

            UpdateProgressColor();

            // the view has now all properties and can be drawn
            _isInitializing = false;
        }
Exemplo n.º 5
0
        private void initButton(Context context, IAttributeSet attrs)
        {
            if (context is Activity)
            {
                init((Activity)context);
            }

            TypedArray a = context.ObtainStyledAttributes(attrs, Resource.Styleable.ShineButton);

            btnColor     = a.GetColor(Resource.Styleable.ShineButton_btn_color, Color.Gray);
            btnFillColor = a.GetColor(Resource.Styleable.ShineButton_btn_fill_color, Color.Black);
            shineParams.allowRandomColor      = a.GetBoolean(Resource.Styleable.ShineButton_allow_random_color, false);
            shineParams.animDuration          = a.GetInteger(Resource.Styleable.ShineButton_shine_animation_duration, (int)shineParams.animDuration);
            shineParams.bigShineColor         = a.GetColor(Resource.Styleable.ShineButton_big_shine_color, shineParams.bigShineColor);
            shineParams.clickAnimDuration     = a.GetInteger(Resource.Styleable.ShineButton_click_animation_duration, (int)shineParams.clickAnimDuration);
            shineParams.enableFlashing        = a.GetBoolean(Resource.Styleable.ShineButton_enable_flashing, false);
            shineParams.shineCount            = a.GetInteger(Resource.Styleable.ShineButton_shine_count, shineParams.shineCount);
            shineParams.shineDistanceMultiple = a.GetFloat(Resource.Styleable.ShineButton_shine_distance_multiple, shineParams.shineDistanceMultiple);
            shineParams.shineTurnAngle        = a.GetFloat(Resource.Styleable.ShineButton_shine_turn_angle, shineParams.shineTurnAngle);
            shineParams.smallShineColor       = a.GetColor(Resource.Styleable.ShineButton_small_shine_color, shineParams.smallShineColor);
            shineParams.smallShineOffsetAngle = a.GetFloat(Resource.Styleable.ShineButton_small_shine_offset_angle, shineParams.smallShineOffsetAngle);
            shineParams.shineSize             = a.GetDimensionPixelSize(Resource.Styleable.ShineButton_shine_size, shineParams.shineSize);
            a.Recycle();
            setSrcColor(btnColor);
        }
        private void LoadAttribute(Context context, IAttributeSet attrs)
        {
            TypedArray typedArray = context.Theme.ObtainStyledAttributes(attrs, Resource.Styleable.MusicBar, 0, 0);

            try
            {
                MLoadedBarSecondaryPaint.Color = typedArray.GetColor(
                    Resource.Styleable.MusicBar_LoadedBarSecondaryColor,
                    ContextCompat.GetColor(context, Resource.Color.LoadedBarSecondaryColor));
                MBackgroundBarSecondaryPaint.Color = typedArray.GetColor(
                    Resource.Styleable.MusicBar_backgroundBarSecondaryColor,
                    ContextCompat.GetColor(context, Resource.Color.BackgroundBarSecondaryColor));
                IsDivided    = typedArray.GetBoolean(Resource.Styleable.MusicBar_divided, false);
                MDividerSize = typedArray.GetFloat(Resource.Styleable.MusicBar_dividerSize, 2);

                MBarWidth = typedArray.GetFloat(Resource.Styleable.MusicBar_barWidth, 3);

                MLoadedBarPrimeColor.StrokeWidth         = MBarWidth;
                MBackgroundBarPrimeColor.StrokeWidth     = MBarWidth;
                MLoadedBarSecondaryPaint.StrokeWidth     = MBarWidth;
                MBackgroundBarSecondaryPaint.StrokeWidth = MBarWidth;

                MDividerSize = MBarWidth + MDividerSize;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            finally
            {
                typedArray.Recycle();
            }
        }
Exemplo n.º 7
0
 public void ApplyTypedArray(TypedArray arr)
 {
     Gravity      = (GravityFlags)arr.GetInt(Resource.Styleable.odometer_android_gravity, (int)Gravity);
     ShadowColor  = arr.GetColor(Resource.Styleable.odometer_android_shadowColor, ShadowColor);
     ShadowDx     = arr.GetFloat(Resource.Styleable.odometer_android_shadowDx, ShadowDx);
     ShadowDy     = arr.GetFloat(Resource.Styleable.odometer_android_shadowDy, ShadowDy);
     ShadowRadius = arr.GetFloat(Resource.Styleable.odometer_android_shadowRadius, ShadowRadius);
     Text         = arr.GetString(Resource.Styleable.odometer_android_text);
     TextColor    = arr.GetColor(Resource.Styleable.odometer_android_textColor, TextColor);
     TextSize     = arr.GetDimension(Resource.Styleable.odometer_android_textSize, TextSize);
     TextStyle    = (TypefaceStyle)arr.GetInt(Resource.Styleable.odometer_android_textStyle, (int)TextStyle);
 }
        private void initAttrs(Context context, IAttributeSet attrs, int defStyle)
        {
            TypedArray a = context.ObtainStyledAttributes(attrs, Resource.Styleable.RecyclerViewPager, defStyle,
                                                          0);

            mFlingFactor         = a.GetFloat(Resource.Styleable.RecyclerViewPager_rvp_flingFactor, 0.15f);
            mTriggerOffset       = a.GetFloat(Resource.Styleable.RecyclerViewPager_rvp_triggerOffset, 0.25f);
            mSinglePageFling     = a.GetBoolean(Resource.Styleable.RecyclerViewPager_rvp_singlePageFling, mSinglePageFling);
            isInertia            = a.GetBoolean(Resource.Styleable.RecyclerViewPager_rvp_inertia, false);
            mMillisecondsPerInch = a.GetFloat(Resource.Styleable.RecyclerViewPager_rvp_millisecondsPerInch, 25f);
            a.Recycle();
        }
Exemplo n.º 9
0
        public ArcLayout(Context context, IAttributeSet attrs)
            : base(context, attrs)
        {
            if (attrs != null)
            {
                TypedArray a = Context.ObtainStyledAttributes(attrs, Resource.Styleable.ArcLayout, 0, 0);
                mFromDegrees = a.GetFloat(Resource.Styleable.ArcLayout_fromDegrees, DEFAULT_FROM_DEGREES);
                mToDegrees   = a.GetFloat(Resource.Styleable.ArcLayout_toDegrees, DEFAULT_TO_DEGREES);
                mChildSize   = Math.Max(a.GetDimensionPixelSize(Resource.Styleable.ArcLayout_childSize, 0), 0);

                a.Recycle();
            }
        }
Exemplo n.º 10
0
        private void init(Context context, Android.Util.IAttributeSet attrs, int defStyle)
        {
            LayoutInflater.From(context).Inflate(Resource.Layout.sat_main, this, true);
            imgMain = FindViewById <ImageView>(Resource.Id.sat_main);

            if (attrs != null)
            {
                TypedArray typedArray = context.ObtainStyledAttributes(attrs, Resource.Styleable.SatelliteMenu, defStyle, 0);
                satelliteDistance  = typedArray.GetDimensionPixelSize(Resource.Styleable.SatelliteMenu_satelliteDistance, DEFAULT_SATELLITE_DISTANCE);
                totalSpacingDegree = typedArray.GetFloat(Resource.Styleable.SatelliteMenu_totalSpacingDegree, DEFAULT_TOTAL_SPACING_DEGREES);
                closeItemsOnClick  = typedArray.GetBoolean(Resource.Styleable.SatelliteMenu_closeOnClick, DEFAULT_CLOSE_ON_CLICK);
                expandDuration     = typedArray.GetInt(Resource.Styleable.SatelliteMenu_expandDuration, DEFAULT_EXPAND_DURATION);
                //float satelliteDistance = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 170, getResources().getDisplayMetrics());
                typedArray.Recycle();
            }


            mainRotateLeft  = SatelliteAnimationCreator.createMainButtonAnimation(context);
            mainRotateRight = SatelliteAnimationCreator.createMainButtonInverseAnimation(context);

            mainRotateLeft.SetAnimationListener(this);
            mainRotateRight.SetAnimationListener(this);
            imgMain.Click += (s, e) =>
            {
                onClick();
            };
            internalItemClickListener = new InternalSatelliteOnClickListener(this);
        }
Exemplo n.º 11
0
        /**
         * Parse the attributes passed to the view from the XML
         *
         * @param a the attributes to parse
         */
        private void ParseAttributes(TypedArray a)
        {
            DisplayMetrics metrics = Context.Resources.DisplayMetrics;// GetContext().getResources().getDisplayMetrics();

            barWidth     = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, barWidth, metrics);
            rimWidth     = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, rimWidth, metrics);
            circleRadius = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, circleRadius,
                                                          metrics);
            circleRadius = (int)a.GetDimension(Resource.Styleable.CircleProgressView_matProg_circleRadius,
                                               circleRadius);
            fillRadius = a.GetBoolean(Resource.Styleable.CircleProgressView_matProg_fillRadius, false);
            barWidth   = (int)a.GetDimension(Resource.Styleable.CircleProgressView_matProg_barWidth, barWidth);
            rimWidth   = (int)a.GetDimension(Resource.Styleable.CircleProgressView_matProg_rimWidth, rimWidth);
            float baseSpinSpeed = a.GetFloat(Resource.Styleable.CircleProgressView_matProg_spinSpeed, spinSpeed / 360.0f);

            spinSpeed        = baseSpinSpeed * 360;
            barSpinCycleTime = a.GetInt(Resource.Styleable.CircleProgressView_matProg_barSpinCycleTime,
                                        (int)barSpinCycleTime);
            barColor       = a.GetColor(Resource.Styleable.CircleProgressView_matProg_barColor, barColor);
            rimColor       = a.GetColor(Resource.Styleable.CircleProgressView_matProg_rimColor, rimColor);
            linearProgress = a.GetBoolean(Resource.Styleable.CircleProgressView_matProg_linearProgress, false);
            if (a.GetBoolean(Resource.Styleable.CircleProgressView_matProg_progressIndeterminate, false))
            {
                Spin();
            }
            a.Recycle();
        }
Exemplo n.º 12
0
        private void init(IAttributeSet attrs, int defStyle)
        {
            TypedArray a = Context.ObtainStyledAttributes(attrs,
                                                          Resource.Styleable.ColorBars, defStyle, 0);
            Resources b = Context.Resources;

            mBarThickness = a.GetDimensionPixelSize(
                Resource.Styleable.ColorBars_bar_thickness,
                b.GetDimensionPixelSize(Resource.Dimension.bar_thickness));
            mBarLength = a.GetDimensionPixelSize(Resource.Styleable.ColorBars_bar_length,
                                                 b.GetDimensionPixelSize(Resource.Dimension.bar_length));
            mPreferredBarLength = mBarLength;
            mBarPointerRadius   = a.GetDimensionPixelSize(
                Resource.Styleable.ColorBars_bar_pointer_radius,
                b.GetDimensionPixelSize(Resource.Dimension.bar_pointer_radius));
            mBarPointerHaloRadius = a.GetDimensionPixelSize(
                Resource.Styleable.ColorBars_bar_pointer_halo_radius,
                b.GetDimensionPixelSize(Resource.Dimension.bar_pointer_halo_radius));
            mOrientation = a.GetBoolean(
                Resource.Styleable.ColorBars_bar_orientation_horizontal, ORIENTATION_DEFAULT);

            int n = a.IndexCount;

            for (int i = 0; i < n; i++)
            {
                int attributeIndex = a.GetIndex(i);
                switch (attributeIndex)
                {
                case Resource.Attribute.bar_corner_radius:
                case Resource.Styleable.ColorBars_bar_corner_radius:
                    try {
                        mCornerRadius = a.GetFloat(attributeIndex, CORNER_RADIUS_DEFAULT);
                    } catch (Exception e) {
                        System.Console.Error.WriteLine(e + ": " + e.Message);
                    }
                    break;

                default:
                    break;
                }
            }


            a.Recycle();

            mBarPaint = new Paint(PaintFlags.AntiAlias);
            mBarPaint.SetShader(shader);

            mBarPointerPosition = (mBarLength / 2) + mBarPointerHaloRadius;

            mBarPointerHaloPaint       = new Paint(PaintFlags.AntiAlias);
            mBarPointerHaloPaint.Color = (Color.Black);
            mBarPointerHaloPaint.Alpha = (0x50);

            mBarPointerPaint       = new Paint(PaintFlags.AntiAlias);
            mBarPointerPaint.Color = new Color(unchecked ((int)(0xff81ff00)));

            mPosToSVFactor = 1 / ((float)mBarLength / 2);
            mSVToPosFactor = ((float)mBarLength / 2) / 1;
        }
Exemplo n.º 13
0
        private void applyAttrs(IAttributeSet attrs)
        {
            if (attrs != null)
            {
                TypedArray a = this.Context.ObtainStyledAttributes(attrs, Resource.Styleable.ArcLayout, 0, 0);

                float fromDegrees = a.GetFloat(Resource.Styleable.ArcLayout_fromDegrees, ArcLayout.DEFAULT_FROM_DEGREES);
                float toDegrees   = a.GetFloat(Resource.Styleable.ArcLayout_toDegrees, ArcLayout.DEFAULT_TO_DEGREES);
                mArcLayout.setArc(fromDegrees, toDegrees);

                int defaultChildSize = mArcLayout.ChildSize;
                int newChildSize     = a.GetDimensionPixelSize(Resource.Styleable.ArcLayout_childSize, defaultChildSize);
                mArcLayout.ChildSize = newChildSize;

                a.Recycle();
            }
        }
Exemplo n.º 14
0
        /**
         * Enables a dark shadow for this CircularImageView.
         * @param shadowEnabled Set to true to render a shadow or false to disable it.
         */
        public void SetShadow(TypedArray attributes)
        {
            this._shadowEnabled = true;
            Color shadowColor  = attributes.GetColor(Resource.Styleable.CircularImageView_shadow_color, Color.Black);
            float shadowRadius = attributes.GetFloat(Resource.Styleable.CircularImageView_shadow_width, 0.0f);

            _paintBorder.SetShadowLayer(shadowRadius, 0.0f, 0.0f, shadowColor);
            _paintSelectorBorder.SetShadowLayer(shadowRadius, 0.0f, 0.0f, shadowColor);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Reads any attributes that were assigned in XML and sets properties appropriately
        /// </summary>
        /// <param name="typedArray">The attributes to apply to the view</param>
        private void InitializeAttributes(TypedArray typedArray)
        {
            string attrConditionName = typedArray.GetString(Resource.Styleable.ConditionResultView_condition_name);

            ConditionName = attrConditionName ?? "";

            Likelihood = typedArray.GetFloat(Resource.Styleable.ConditionResultView_condition_likelihood, 0);

            string attrLikelihoodLabel = typedArray.GetString(Resource.Styleable.ConditionResultView_condition_likelihood_label);

            LikelihoodLabel = attrLikelihoodLabel ?? "";
        }
Exemplo n.º 16
0
        public RealtimeBlurView(Context context, IAttributeSet attrs) : base(context, attrs)
        {
            TypedArray a = context.ObtainStyledAttributes(attrs, R.Styleable.RealtimeBlurView);

            mBlurRadius = a.GetDimension(R.Styleable.RealtimeBlurView_realtimeBlurRadius,
                                         TypedValue.ApplyDimension(ComplexUnitType.Dip, 10, context.Resources.DisplayMetrics));
            mDownsampleFactor = a.GetFloat(R.Styleable.RealtimeBlurView_realtimeDownsampleFactor, 4);
            mOverlayColor     = a.GetColor(R.Styleable.RealtimeBlurView_realtimeOverlayColor, Color.Argb(0xaa, 255, 255, 255).ToArgb());
            a.Recycle();

            mPaint          = new Paint();
            preDrawListener = new MyPreDrawListener(this);
        }
            public void ReadStyleParameters(Context context, IAttributeSet attributeSet)
            {
                TypedArray a = context.ObtainStyledAttributes(attributeSet, Resource.Styleable.FlowLayout_LayoutParams);

                try
                {
                    this.newLine = a.GetBoolean(Resource.Styleable.FlowLayout_LayoutParams_layout_newLine, false);
                    this.gravity = (GravityFlags)a.GetInt(Resource.Styleable.FlowLayout_LayoutParams_android_layout_gravity, (int)GravityFlags.NoGravity);
                    this.weight  = a.GetFloat(Resource.Styleable.FlowLayout_LayoutParams_layout_weight, -1.0f);
                }
                finally
                {
                    a.Recycle();
                }
            }
Exemplo n.º 18
0
        public VotingPowerFrame(Context context, IAttributeSet attrs) : base(context, attrs)
        {
            SetWillNotDraw(false);
            TypedArray ta = null;

            try
            {
                ta               = context.ObtainStyledAttributes(attrs, Resource.Styleable.VotingPowerFrame, 0, 0);
                VotingPower      = ta.GetFloat(Resource.Styleable.VotingPowerFrame_votingPower, 100.0f);
                VotingPowerWidth = ta.GetDimensionPixelSize(Resource.Styleable.VotingPowerFrame_votingPowerWidth, 5);
            }
            finally
            {
                ta?.Recycle();
            }
        }
        private void Init(Context context, IAttributeSet attrs)
        {
            DiagonalPosition  = DiagonalPosition.Top;
            DiagonalDirection = DiagonalDirection.Right;
            DiagonalAngle     = 0f;

            if (attrs != null)
            {
                TypedArray attributes = context.ObtainStyledAttributes(attrs, Resource.Styleable.DiagonalView);
                DiagonalAngle     = attributes.GetFloat(Resource.Styleable.DiagonalView_shape_diagonal_angle, DiagonalAngle);
                DiagonalPosition  = (DiagonalPosition)attributes.GetInteger(Resource.Styleable.DiagonalView_shape_diagonal_position, (int)DiagonalPosition);
                DiagonalDirection = (DiagonalDirection)attributes.GetInteger(Resource.Styleable.DiagonalView_shape_diagonal_direction, (int)DiagonalDirection);
                attributes.Recycle();
            }
            SetClipPathCreator(this);
        }
Exemplo n.º 20
0
        public LayoutConfiguration(Context context, IAttributeSet attributeSet)
        {
            TypedArray a = context.ObtainStyledAttributes(attributeSet, Resource.Styleable.FlowLayout);

            try
            {
                this.Orientation   = a.GetInteger(Resource.Styleable.FlowLayout_android_orientation, FlowLayout.HORIZONTAL);
                this.DebugDraw     = a.GetBoolean(Resource.Styleable.FlowLayout_debugDraw, false);
                this.WeightDefault = a.GetFloat(Resource.Styleable.FlowLayout_weightDefault, 0.0f);
                this.Gravity       = (GravityFlags)a.GetInteger(Resource.Styleable.FlowLayout_android_gravity, (int)GravityFlags.NoGravity);
                this.Direction     = a.GetInteger(Resource.Styleable.FlowLayout_layoutDirection, FlowLayout.LAYOUT_DIRECTION_LTR);
            }
            finally
            {
                a.Recycle();
            }
        }
Exemplo n.º 21
0
        private void ApplyAttrs(Context context, IAttributeSet attrs)
        {
            TypedArray a = context.ObtainStyledAttributes(attrs, Resource.Styleable.Gauge, 0, 0);

            TotalNicks             = a.GetInt(Resource.Styleable.Gauge_totalNicks, totalNicks);
            degreesPerNick         = 360.0f / totalNicks;
            valuePerNick           = a.GetFloat(Resource.Styleable.Gauge_valuePerNick, valuePerNick);
            majorNickInterval      = a.GetInt(Resource.Styleable.Gauge_majorNickInterval, 10);
            minValue               = a.GetFloat(Resource.Styleable.Gauge_minValue, minValue);
            maxValue               = a.GetFloat(Resource.Styleable.Gauge_maxValue, maxValue);
            intScale               = a.GetBoolean(Resource.Styleable.Gauge_intScale, intScale);
            initialValue           = a.GetFloat(Resource.Styleable.Gauge_initialValue, initialValue);
            requestedLabelTextSize = a.GetFloat(Resource.Styleable.Gauge_labelTextSize, requestedLabelTextSize);
            faceColor              = a.GetColor(Resource.Styleable.Gauge_faceColor, Color.Argb(0xff, 0xff, 0xff, 0xff));
            needleShadow           = a.GetBoolean(Resource.Styleable.Gauge_needleShadow, needleShadow);
            requestedTextSize      = a.GetFloat(Resource.Styleable.Gauge_textSize, requestedTextSize);
            upperText              = a.GetString(Resource.Styleable.Gauge_upperText) == null ? upperText : FromHtml(a.GetString(Resource.Styleable.Gauge_upperText)).ToString();
            lowerText              = a.GetString(Resource.Styleable.Gauge_lowerText) == null ? lowerText : FromHtml(a.GetString(Resource.Styleable.Gauge_lowerText)).ToString();
            requestedUpperTextSize = a.GetFloat(Resource.Styleable.Gauge_upperTextSize, 0);
            requestedLowerTextSize = a.GetFloat(Resource.Styleable.Gauge_lowerTextSize, 0);
            a.Recycle();
        }
Exemplo n.º 22
0
        protected void initByAttributes(TypedArray attributes)
        {
            finishedStrokeColor   = attributes.GetColor(Resource.Styleable.DonutProgress_donut_finished_color, default_finished_color);
            unfinishedStrokeColor = attributes.GetColor(Resource.Styleable.DonutProgress_donut_unfinished_color, default_unfinished_color);
            showText            = attributes.GetBoolean(Resource.Styleable.DonutProgress_donut_show_text, true);
            attributeResourceId = attributes.GetResourceId(Resource.Styleable.DonutProgress_donut_inner_drawable, 0);

            setMax(attributes.GetInt(Resource.Styleable.DonutProgress_donut_max, default_max));
            setProgress(attributes.GetFloat(Resource.Styleable.DonutProgress_donut_progress, 0));
            finishedStrokeWidth   = attributes.GetDimension(Resource.Styleable.DonutProgress_donut_finished_stroke_width, default_stroke_width);
            unfinishedStrokeWidth = attributes.GetDimension(Resource.Styleable.DonutProgress_donut_unfinished_stroke_width, default_stroke_width);

            if (showText)
            {
                if (attributes.GetString(Resource.Styleable.DonutProgress_donut_prefix_text) != null)
                {
                    prefixText = attributes.GetString(Resource.Styleable.DonutProgress_donut_prefix_text);
                }
                if (attributes.GetString(Resource.Styleable.DonutProgress_donut_suffix_text) != null)
                {
                    suffixText = attributes.GetString(Resource.Styleable.DonutProgress_donut_suffix_text);
                }
                if (attributes.GetString(Resource.Styleable.DonutProgress_donut_text) != null)
                {
                    text = attributes.GetString(Resource.Styleable.DonutProgress_donut_text);
                }

                textColor            = attributes.GetColor(Resource.Styleable.DonutProgress_donut_text_color, default_text_color);
                textSize             = attributes.GetDimension(Resource.Styleable.DonutProgress_donut_text_size, default_text_size);
                innerBottomTextSize  = attributes.GetDimension(Resource.Styleable.DonutProgress_donut_inner_bottom_text_size, default_inner_bottom_text_size);
                innerBottomTextColor = attributes.GetColor(Resource.Styleable.DonutProgress_donut_inner_bottom_text_color, default_inner_bottom_text_color);
                innerBottomText      = attributes.GetString(Resource.Styleable.DonutProgress_donut_inner_bottom_text);
            }

            innerBottomTextSize  = attributes.GetDimension(Resource.Styleable.DonutProgress_donut_inner_bottom_text_size, default_inner_bottom_text_size);
            innerBottomTextColor = attributes.GetColor(Resource.Styleable.DonutProgress_donut_inner_bottom_text_color, default_inner_bottom_text_color);
            innerBottomText      = attributes.GetString(Resource.Styleable.DonutProgress_donut_inner_bottom_text);

            startingDegree       = attributes.GetInt(Resource.Styleable.DonutProgress_donut_circle_starting_degree, default_startingDegree);
            innerBackgroundColor = attributes.GetColor(Resource.Styleable.DonutProgress_donut_background_color, default_inner_background_color);
        }
Exemplo n.º 23
0
        private void InitalizeAttributes(IAttributeSet attrs, int defStyle)
        {
            TypedArray a = Context.ObtainStyledAttributes(attrs, Resource.Styleable.PullToRefresharpWrapper, defStyle, 0);

            header_res_id       = a.GetResourceId(Resource.Styleable.PullToRefresharpWrapper_headerId, 0);
            content_view_res_id = a.GetResourceId(Resource.Styleable.PullToRefresharpWrapper_contentViewId, 0);
            pulldown_progress_indicator_res_id = a.GetResourceId(Resource.Styleable.PullToRefresharpWrapper_pullDownProgressIndicatorId, 0);

            pull_to_refresh_string_id = a.GetResourceId(Resource.Styleable.PullToRefresharpWrapper_pullToRefreshText,
                                                        Resource.String.ptrsharp_pull_to_refresh);
            release_to_refresh_string_id = a.GetResourceId(Resource.Styleable.PullToRefresharpWrapper_releaseToRefreshText,
                                                           Resource.String.ptrsharp_release_to_refresh);
            refreshing_string_id = a.GetResourceId(Resource.Styleable.PullToRefresharpWrapper_refreshingText,
                                                   Resource.String.ptrsharp_refreshing);

            header_background_res_id = a.GetResourceId(Resource.Styleable.PullToRefresharpWrapper_ptrHeaderBackground, 0);
            header_text_color        = a.GetColorStateList(Resource.Styleable.PullToRefresharpWrapper_headerTextColor);

            pulldown_icon_drawable_res_id = a.GetResourceId(Resource.Styleable.PullToRefresharpWrapper_headerIconDrawable, 0);

            pulldown_tension_factor = a.GetFloat(Resource.Styleable.PullToRefresharpWrapper_pullDownTension, 0.5f);
            SnapbackDuration        = a.GetInt(Resource.Styleable.PullToRefresharpWrapper_snapbackDuration, 400);
            IsPullEnabled           = a.GetBoolean(Resource.Styleable.PullToRefresharpWrapper_pullEnabled, true);

            fastscroll_thumb_width = a.GetDimensionPixelSize(Resource.Styleable.PullToRefresharpWrapper_fastScrollThumbWidth, -1);
            if (fastscroll_thumb_width < 0)
            {
                fastscroll_thumb_width = Resources.GetDimensionPixelSize(Resource.Dimension.fastscroll_thumb_width);
            }

            // Enforce the constraint that both or none of the attributes headerId and viewId are set
            if (header_res_id > 0 && content_view_res_id == 0 || content_view_res_id > 0 && header_res_id == 0)
            {
                throw new ArgumentException("Both headerId and contentViewId must be either set or not set, setting just one is not supported");
            }

            a.Recycle();
        }
Exemplo n.º 24
0
        private void LoadAttribute(Context context, IAttributeSet attrs)
        {
            TypedArray typedArray = context.Theme.ObtainStyledAttributes(attrs, Resource.Styleable.MusicBar, 0, 0);

            try
            {
                MSpaceBetweenBar = typedArray.GetInteger(Resource.Styleable.MusicBar_spaceBetweenBar, 2);

                MBarWidth = typedArray.GetFloat(Resource.Styleable.MusicBar_barWidth, 2);
                MLoadedBarPrimeColor.StrokeWidth     = MBarWidth;
                MBackgroundBarPrimeColor.StrokeWidth = MBarWidth;

                MLoadedBarPrimeColor.Color     = typedArray.GetColor(Resource.Styleable.MusicBar_LoadedBarPrimeColor, ContextCompat.GetColor(context, Resource.Color.LoadedBarPrimeColor));
                MBackgroundBarPrimeColor.Color = typedArray.GetColor(Resource.Styleable.MusicBar_backgroundBarPrimeColor, ContextCompat.GetColor(context, Resource.Color.BackgroundBarPrimeColor));
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
            finally
            {
                typedArray.Recycle();
            }
        }
        /**
         * Retrieve attributes from the MaterialViewPager
         * @param context
         * @param attrs
         */

        public void HandleAttributes(Context context, IAttributeSet attrs)
        {
            try
            {
                TypedArray styledAttrs = context.ObtainStyledAttributes(attrs, Resource.Styleable.MaterialViewPager);

                {
                    HeaderLayoutId = styledAttrs.GetResourceId(Resource.Styleable.MaterialViewPager_viewpager_header, -1);
                }
                {
                    PagerTitleStripId = styledAttrs.GetResourceId(Resource.Styleable.MaterialViewPager_viewpager_pagerTitleStrip, -1);
                    if (PagerTitleStripId == -1)
                    {
                        PagerTitleStripId = Resource.Layout.material_view_pager_pagertitlestrip_standard;
                    }
                }
                {
                    LogoLayoutId  = styledAttrs.GetResourceId(Resource.Styleable.MaterialViewPager_viewpager_logo, -1);
                    LogoMarginTop = styledAttrs.GetDimensionPixelSize(Resource.Styleable.MaterialViewPager_viewpager_logoMarginTop, 0);
                }
                {
                    Color = styledAttrs.GetColor(Resource.Styleable.MaterialViewPager_viewpager_color, 0);
                }
                {
                    HeaderHeightPx = styledAttrs.GetDimensionPixelOffset(Resource.Styleable.MaterialViewPager_viewpager_headerHeight, 200);
                    HeaderHeight   = Math.Round(Utils.PxToDp(HeaderHeightPx, context));                   //convert to dp
                }
                {
                    HeaderAdditionalHeight = styledAttrs.GetDimensionPixelOffset(Resource.Styleable.MaterialViewPager_viewpager_headerAdditionalHeight, 60);
                }
                {
                    HeaderAlpha = styledAttrs.GetFloat(Resource.Styleable.MaterialViewPager_viewpager_headerAlpha, 0.5f);
                }
                {
                    ParallaxHeaderFactor = styledAttrs.GetFloat(Resource.Styleable.MaterialViewPager_viewpager_parallaxHeaderFactor, 1.5f);
                    ParallaxHeaderFactor = Math.Max(ParallaxHeaderFactor, 1);                     //min=1
                }
                {
                    HideToolbarAndTitle = styledAttrs.GetBoolean(Resource.Styleable.MaterialViewPager_viewpager_hideToolbarAndTitle, false);
                    HideLogoWithFade    = styledAttrs.GetBoolean(Resource.Styleable.MaterialViewPager_viewpager_hideLogoWithFade, false);
                }
                {
                    EnableToolbarElevation = styledAttrs.GetBoolean(Resource.Styleable.MaterialViewPager_viewpager_enableToolbarElevation, false);
                }
                {
                    DisplayToolbarWhenSwipe = styledAttrs.GetBoolean(Resource.Styleable.MaterialViewPager_viewpager_displayToolbarWhenSwipe, false);
                }
                {
                    ToolbarTransparent = styledAttrs.GetBoolean(Resource.Styleable.MaterialViewPager_viewpager_transparentToolbar, false);
                }
                {
                    AnimatedHeaderImage = styledAttrs.GetBoolean(Resource.Styleable.MaterialViewPager_viewpager_animatedHeaderImage, true);
                }
                {
                    DisableToolbar = styledAttrs.GetBoolean(Resource.Styleable.MaterialViewPager_viewpager_disableToolbar, false);
                }
                styledAttrs.Recycle();
            }
            catch (Exception)
            {
                // ignored
            }
        }
Exemplo n.º 26
0
        private void ReadAttrs(Context context, IAttributeSet attrs, int defStyle)
        {
            TypedArray typedArray = context.ObtainStyledAttributes(attrs, Resource.Styleable.GaugeView, defStyle, 0);

            mShowOuterShadow = typedArray.GetBoolean(Resource.Styleable.GaugeView_showOuterShadow, SHOW_OUTER_SHADOW);
            mShowOuterBorder = typedArray.GetBoolean(Resource.Styleable.GaugeView_showOuterBorder, SHOW_OUTER_BORDER);
            mShowOuterRim    = typedArray.GetBoolean(Resource.Styleable.GaugeView_showOuterRim, SHOW_OUTER_RIM);
            mShowInnerRim    = typedArray.GetBoolean(Resource.Styleable.GaugeView_showInnerRim, SHOW_INNER_RIM);
            mShowNeedle      = typedArray.GetBoolean(Resource.Styleable.GaugeView_showNeedle, SHOW_NEEDLE);
            mShowScale       = typedArray.GetBoolean(Resource.Styleable.GaugeView_showScale, SHOW_SCALE);
            mShowRanges      = typedArray.GetBoolean(Resource.Styleable.GaugeView_showRanges, SHOW_RANGES);
            mShowText        = typedArray.GetBoolean(Resource.Styleable.GaugeView_showText, SHOW_TEXT);

            mOuterShadowWidth    = mShowOuterShadow ? typedArray.GetFloat(Resource.Styleable.GaugeView_outerShadowWidth, OUTER_SHADOW_WIDTH) : 0.0f;
            mOuterBorderWidth    = mShowOuterBorder ? typedArray.GetFloat(Resource.Styleable.GaugeView_outerBorderWidth, OUTER_BORDER_WIDTH) : 0.0f;
            mOuterRimWidth       = mShowOuterRim ? typedArray.GetFloat(Resource.Styleable.GaugeView_outerRimWidth, OUTER_RIM_WIDTH) : 0.0f;
            mInnerRimWidth       = mShowInnerRim ? typedArray.GetFloat(Resource.Styleable.GaugeView_innerRimWidth, INNER_RIM_WIDTH) : 0.0f;
            mInnerRimBorderWidth = mShowInnerRim ? typedArray.GetFloat(Resource.Styleable.GaugeView_innerRimBorderWidth, INNER_RIM_BORDER_WIDTH) : 0.0f;

            mNeedleWidth  = typedArray.GetFloat(Resource.Styleable.GaugeView_needleWidth, NEEDLE_WIDTH);
            mNeedleHeight = typedArray.GetFloat(Resource.Styleable.GaugeView_needleHeight, NEEDLE_HEIGHT);

            mScalePosition   = (mShowScale || mShowRanges) ? typedArray.GetFloat(Resource.Styleable.GaugeView_scalePosition, SCALE_POSITION) : 0.0f;
            mScaleStartValue = typedArray.GetFloat(Resource.Styleable.GaugeView_scaleStartValue, SCALE_START_VALUE);
            mScaleEndValue   = typedArray.GetFloat(Resource.Styleable.GaugeView_scaleEndValue, SCALE_END_VALUE);
            mScaleStartAngle = typedArray.GetFloat(Resource.Styleable.GaugeView_scaleStartAngle, SCALE_START_ANGLE);
            mScaleEndAngle   = typedArray.GetFloat(Resource.Styleable.GaugeView_scaleEndAngle, 360.0f - mScaleStartAngle);

            mDivisions    = typedArray.GetInteger(Resource.Styleable.GaugeView_divisions, SCALE_DIVISIONS);
            mSubdivisions = typedArray.GetInteger(Resource.Styleable.GaugeView_subdivisions, SCALE_SUBDIVISIONS);

            if (mShowRanges)
            {
                mTextShadowColor = typedArray.GetColor(Resource.Styleable.GaugeView_textShadowColor, TEXT_SHADOW_COLOR);

                string[] rangeValues = typedArray.GetTextArray(Resource.Styleable.GaugeView_rangeValues);
                string[] rangeColors = typedArray.GetTextArray(Resource.Styleable.GaugeView_rangeColors);
                ReadRanges(rangeValues, rangeColors);
            }

            if (mShowText)
            {
                int    textValueId = typedArray.GetResourceId(Resource.Styleable.GaugeView_textValue, 0);
                string textValue   = typedArray.GetString(Resource.Styleable.GaugeView_textValue);
                mTextValue = (0 < textValueId) ? context.GetString(textValueId) : (null != textValue) ? textValue : "";

                int    textUnitId = typedArray.GetResourceId(Resource.Styleable.GaugeView_textUnit, 0);
                string textUnit   = typedArray.GetString(Resource.Styleable.GaugeView_textUnit);
                mTextUnit        = (0 < textUnitId) ? context.GetString(textUnitId) : (null != textUnit) ? textUnit : "";
                mTextValueColor  = typedArray.GetColor(Resource.Styleable.GaugeView_textValueColor, TEXT_VALUE_COLOR);
                mTextUnitColor   = typedArray.GetColor(Resource.Styleable.GaugeView_textUnitColor, TEXT_UNIT_COLOR);
                mTextShadowColor = typedArray.GetColor(Resource.Styleable.GaugeView_textShadowColor, TEXT_SHADOW_COLOR);

                mTextValueSize = typedArray.GetFloat(Resource.Styleable.GaugeView_textValueSize, TEXT_VALUE_SIZE);
                mTextUnitSize  = typedArray.GetFloat(Resource.Styleable.GaugeView_textUnitSize, TEXT_UNIT_SIZE);
            }

            typedArray.Recycle();
        }
        /// <summary>
        /// Instantiates a new SlidingMenu.
        /// </summary>
        /// <param name="context"> the associated Context </param>
        /// <param name="attrs"> the attrs </param>
        /// <param name="defStyle"> the def style </param>
        public SlidingMenu(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle)
        {
            LayoutParams behindParams = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);

            mViewBehind = new CustomViewBehind(context);
            AddView(mViewBehind, behindParams);
            LayoutParams aboveParams = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);

            mViewAbove = new CustomViewAbove(context);
            AddView(mViewAbove, aboveParams);
            // register the CustomViewBehind with the CustomViewAbove
            mViewAbove.CustomViewBehind = mViewBehind;
            mViewBehind.CustomViewAbove = mViewAbove;
            mViewAbove.SetInternalPageChangeListener(new MyOnPageChangeListener(this));

            // now style everything!
            TypedArray ta = context.ObtainStyledAttributes(attrs, Resource.Styleable.SlidingMenu);
            // set the above and behind views if defined in xml
            int mode = ta.GetInt(Resource.Styleable.SlidingMenu_mode, LEFT);

            Mode = mode;
            int viewAbove = ta.GetResourceId(Resource.Styleable.SlidingMenu_viewAbove, -1);

            if (viewAbove != -1)
            {
                SetContent(viewAbove);
            }
            else
            {
                SetContent(new FrameLayout(context));
            }
            int viewBehind = ta.GetResourceId(Resource.Styleable.SlidingMenu_viewBehind, -1);

            if (viewBehind != -1)
            {
                SetMenu(viewBehind);
            }
            else
            {
                SetMenu(new FrameLayout(context));
            }
            int touchModeAbove = ta.GetInt(Resource.Styleable.SlidingMenu_touchModeAbove, TOUCHMODE_MARGIN);

            TouchModeAbove = touchModeAbove;
            int touchModeBehind = ta.GetInt(Resource.Styleable.SlidingMenu_touchModeBehind, TOUCHMODE_MARGIN);

            TouchModeBehind = touchModeBehind;

            int offsetBehind = (int)ta.GetDimension(Resource.Styleable.SlidingMenu_behindOffset, -1);
            int widthBehind  = (int)ta.GetDimension(Resource.Styleable.SlidingMenu_behindWidth, -1);

            if (offsetBehind != -1 && widthBehind != -1)
            {
                throw new IllegalStateException("Cannot set both behindOffset and behindWidth for a SlidingMenu");
            }
            else if (offsetBehind != -1)
            {
                BehindOffset = offsetBehind;
            }
            else if (widthBehind != -1)
            {
                BehindWidth = widthBehind;
            }
            else
            {
                BehindOffset = 0;
            }
            float scrollOffsetBehind = ta.GetFloat(Resource.Styleable.SlidingMenu_behindScrollScale, 0.33f);

            BehindScrollScale = scrollOffsetBehind;
            int shadowRes = ta.GetResourceId(Resource.Styleable.SlidingMenu_shadowDrawable, -1);

            if (shadowRes != -1)
            {
                ShadowDrawableResource = shadowRes;
            }
            int shadowWidth = (int)ta.GetDimension(Resource.Styleable.SlidingMenu_shadowWidth, 0);

            ShadowWidth = shadowWidth;
            bool fadeEnabled = ta.GetBoolean(Resource.Styleable.SlidingMenu_fadeEnabled, true);

            FadeEnabled = fadeEnabled;
            float fadeDeg = ta.GetFloat(Resource.Styleable.SlidingMenu_fadeDegree, 0.33f);

            FadeDegree = fadeDeg;
            bool selectorEnabled = ta.GetBoolean(Resource.Styleable.SlidingMenu_selectorEnabled, false);

            SelectorEnabled = selectorEnabled;
            int selectorRes = ta.GetResourceId(Resource.Styleable.SlidingMenu_selectorDrawable, -1);

            if (selectorRes != -1)
            {
                SelectorDrawable = selectorRes;
            }
            ta.Recycle();
        }
Exemplo n.º 28
0
        private float ExtractNumericValueFromAttributes(TypedArray a, int attribute, int defaultValue)
        {
            var tv = a.PeekValue(attribute);

            return(tv == null ? defaultValue : a.GetFloat(attribute, defaultValue));
        }
Exemplo n.º 29
0
        protected void Init(Context context, IAttributeSet attrs)
        {
            if (IsInEditMode)
            {
                return;
            }

            if (null == attrs)
            {
                throw new IllegalArgumentException("Attributes should be provided to this view,");
            }

            TypedArray typedArray = context.ObtainStyledAttributes(attrs, Resource.Styleable.RippleBackground);

            rippleColor        = typedArray.GetColor(Resource.Styleable.RippleBackground_rb_rippleColour, -1);
            rippleStrokeWidth  = typedArray.GetDimension(Resource.Styleable.RippleBackground_rb_strokeWidth, Resource.Dimension.rippleStrokeWidth);
            rippleRadius       = typedArray.GetDimension(Resource.Styleable.RippleBackground_rb_radius, Resource.Dimension.rippleRadius);
            rippleDurationTime = typedArray.GetInt(Resource.Styleable.RippleBackground_rb_duration, DEFAULT_DURATION_TIME);
            rippleAmount       = typedArray.GetInt(Resource.Styleable.RippleBackground_rb_rippleAmount, DEFAULT_RIPPLE_COUNT);
            rippleScale        = typedArray.GetFloat(Resource.Styleable.RippleBackground_rb_scale, DEFAULT_SCALE);
            rippleType         = typedArray.GetInt(Resource.Styleable.RippleBackground_rb_type, DEFAULT_FILL_TYPE);
            RippleOnClick      = typedArray.GetBoolean(Resource.Styleable.RippleBackground_rb_rippleOnClick, true);
            typedArray.Recycle();

            rippleDelay = rippleDurationTime / rippleAmount;

            paint = new Paint
            {
                AntiAlias = true
            };

            if (rippleType == DEFAULT_FILL_TYPE)
            {
                rippleStrokeWidth = 0;
                paint.SetStyle(Paint.Style.Fill);
            }
            else
            {
                paint.SetStyle(Paint.Style.Stroke);
            }

            // set colour
            if (rippleColor == -1)
            {
                paint.Color = Color.DarkBlue;
            }
            else
            {
                paint.Color = new Color(rippleColor);
            }

            rippleParams = new LayoutParams((int)(2 * (rippleRadius + rippleStrokeWidth)), (int)(2 * (rippleRadius + rippleStrokeWidth)));
            rippleParams.AddRule(LayoutRules.CenterInParent, 1);

            animatorSet = new AnimatorSet();
            animatorSet.SetInterpolator(new AccelerateDecelerateInterpolator());
            animatorList = new JavaList <Animator>();

            for (int i = 0; i < rippleAmount; i++)
            {
                RippleView rippleView = new RippleView(Context, rippleStrokeWidth, paint);
                AddView(rippleView, rippleParams);
                rippleViewList.Add(rippleView);

                ObjectAnimator scaleXAnimator = ObjectAnimator.OfFloat(rippleView, "ScaleX", 1.0f, rippleScale);
                scaleXAnimator.RepeatCount = ValueAnimator.Infinite;
                scaleXAnimator.RepeatMode  = ValueAnimatorRepeatMode.Restart;
                scaleXAnimator.StartDelay  = (i * rippleDelay);
                scaleXAnimator.SetDuration(rippleDurationTime);
                animatorList.Add(scaleXAnimator);

                ObjectAnimator scaleYAnimator = ObjectAnimator.OfFloat(rippleView, "ScaleY", 1.0f, rippleScale);
                scaleYAnimator.RepeatCount = ValueAnimator.Infinite;
                scaleYAnimator.RepeatMode  = ValueAnimatorRepeatMode.Restart;
                scaleYAnimator.StartDelay  = (i * rippleDelay);
                scaleYAnimator.SetDuration(rippleDurationTime);
                animatorList.Add(scaleYAnimator);

                ObjectAnimator alphaAnimator = ObjectAnimator.OfFloat(rippleView, "Alpha", 1.0f, 0f);
                alphaAnimator.RepeatCount = ValueAnimator.Infinite;
                alphaAnimator.RepeatMode  = ValueAnimatorRepeatMode.Restart;
                alphaAnimator.StartDelay  = (i * rippleDelay);
                alphaAnimator.SetDuration(rippleDurationTime);
                animatorList.Add(alphaAnimator);
            }

            // set up click event
            Click += RippleBackground_Click;

            animatorSet.PlayTogether(animatorList);
        }
Exemplo n.º 30
0
 public float GetFloat(int index, float defValue)
 {
     return(_array.GetFloat(index, defValue));
 }