private void Init(Android.Content.Context context, IAttributeSet attrs, int p)
        {
            TypedArray a       = context.ObtainStyledAttributes(attrs, Resource.Styleable.CircleProgressBar, p, 0);
            float      density = context.Resources.DisplayMetrics.Density;

            mBackGroundColor         = a.GetColor(Resource.Styleable.CircleProgressBar_mlpb_background_color, DEFAULT_CIRCLE_BG_LIGHT);
            mProgressColor           = a.GetColor(Resource.Styleable.CircleProgressBar_mlpb_progress_color, DEFAULT_CIRCLE_BG_LIGHT);
            mInnerRadius             = a.GetDimensionPixelOffset(Resource.Styleable.CircleProgressBar_mlpb_inner_radius, -1);
            mProgressStokeWidth      = a.GetDimensionPixelOffset(Resource.Styleable.CircleProgressBar_mlpb_progress_stoke_width, (int)(STROKE_WIDTH_LARGE * density));
            mArrowWidth              = a.GetDimensionPixelOffset(Resource.Styleable.CircleProgressBar_mlpb_arrow_width, -1);
            mArrowHeight             = a.GetDimensionPixelOffset(Resource.Styleable.CircleProgressBar_mlpb_arrow_height, -1);
            mTextSize                = a.GetDimensionPixelOffset(Resource.Styleable.CircleProgressBar_mlpb_progress_text_size, (int)(DEFAULT_TEXT_SIZE * density));
            mTextColor               = a.GetColor(Resource.Styleable.CircleProgressBar_mlpb_progress_text_color, Color.Black);
            mShowArrow               = a.GetBoolean(Resource.Styleable.CircleProgressBar_mlpb_show_arrow, false);
            mCircleBackgroundEnabled = a.GetBoolean(Resource.Styleable.CircleProgressBar_mlpb_enable_circle_background, true);

            mProgress = a.GetInt(Resource.Styleable.CircleProgressBar_mlpb_progress, 0);
            mMax      = a.GetInt(Resource.Styleable.CircleProgressBar_mlpb_max, 100);
            int textVisible = a.GetInt(Resource.Styleable.CircleProgressBar_mlpb_progress_text_visibility, 1);

            if (textVisible != 1)
            {
                mIfDrawText = true;
            }

            mTextPaint = new Paint();
            mTextPaint.SetStyle(Paint.Style.Fill);
            mTextPaint.Color     = mTextColor;
            mTextPaint.TextSize  = mTextSize;
            mTextPaint.AntiAlias = true;
            a.Recycle();
            mProgressDrawable = new MaterialProgressDrawale(Context, this);
            base.SetImageDrawable(mProgressDrawable);
        }
        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();
                }
            }
        }
Пример #3
0
        private void Init(Context context, IAttributeSet attrs)
        {
            ConstructModel();
            counterTextViewModel.stop = fixedStop;
            elapsedSecond             = fixedStop;
            TypedArray ta = context.ObtainStyledAttributes(attrs, Resource.Styleable.CounterTextView, 0, 0);

            try
            {
                counterTextViewModel.progression = ta.GetInt(Resource.Styleable.CounterTextView_progression, 1);
                counterTextViewModel.stop        = ta.GetInt(Resource.Styleable.CounterTextView_stop, -11111111);
                counterTextViewModel.StopText    = ta.GetString(Resource.Styleable.CounterTextView_stopText);
                counterTextViewModel.start       = ta.GetInt(Resource.Styleable.CounterTextView_start, 0);
                counterTextViewModel.StartText   = ta.GetString(Resource.Styleable.CounterTextView_startText);
                counterTextViewModel.interval    = ta.GetInt(Resource.Styleable.CounterTextView_interval, 1000);
                counterTextViewModel.future      = ta.GetInt(Resource.Styleable.CounterTextView_future, 0);
                counterTextViewModel.repeat      = ta.GetBoolean(Resource.Styleable.CounterTextView_repeat, false);
                if (counterTextViewModel.future > 0)
                {
                    futureDone = true;
                }
            }
            finally
            {
                ta.Recycle();
            }
            lastnumber = counterTextViewModel.start;;
            SetText();
        }
        private void handleTypedArray(Context context, IAttributeSet attrs)
        {
            if (attrs == null)
            {
                return;
            }

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

            this.mIndicatorWidth  = typedArray.GetDimensionPixelSize(Resource.Styleable.CircleIndicator_ci_width, -1);
            this.mIndicatorHeight = typedArray.GetDimensionPixelSize(Resource.Styleable.CircleIndicator_ci_height, -1);
            this.mIndicatorMargin = typedArray.GetDimensionPixelSize(Resource.Styleable.CircleIndicator_ci_margin, -1);

            this.mAnimatorResId = typedArray.GetResourceId(Resource.Styleable.CircleIndicator_ci_animator,
                                                           Resource.Animator.scale_with_alpha);
            this.mAnimatorReverseResId =
                typedArray.GetResourceId(Resource.Styleable.CircleIndicator_ci_animator_reverse, 0);
            this.mIndicatorBackgroundResId = typedArray.GetResourceId(Resource.Styleable.CircleIndicator_ci_drawable,
                                                                      Resource.Drawable.white_radius);
            this.mIndicatorUnselectedBackgroundResId =
                typedArray.GetResourceId(Resource.Styleable.CircleIndicator_ci_drawable_unselected,
                                         this.mIndicatorBackgroundResId);

            Android.Widget.Orientation orientation =
                (Android.Widget.Orientation)typedArray.GetInt(Resource.Styleable.CircleIndicator_ci_orientation, -1);
            Orientation = (orientation == Android.Widget.Orientation.Vertical
                ? Android.Widget.Orientation.Vertical
                : Android.Widget.Orientation.Horizontal);

            int gravity = typedArray.GetInt(Resource.Styleable.CircleIndicator_ci_gravity, -1);

            SetGravity((gravity >= 0 ? (GravityFlags)gravity : GravityFlags.Center));

            typedArray.Recycle();
        }
Пример #5
0
        public RVPIndicator(Context context, IAttributeSet attrs) : base(context, attrs)
        {
            mIndicatorWidth = Width / mTabVisibleCount;
            // 获得自定义属性
            TypedArray a = context.ObtainStyledAttributes(attrs,
                                                          Resource.Styleable.RVPIndicator);

            mTabVisibleCount = a.GetInt(Resource.Styleable.RVPIndicator_item_count,
                                        D_TAB_COUNT);
            mTextColorNormal = a
                               .GetColor(Resource.Styleable.RVPIndicator_text_color_normal,
                                         D_TEXT_COLOR_NORMAL);
            mTextColorHighlight = a.GetColor(
                Resource.Styleable.RVPIndicator_text_color_hightlight,
                D_TEXT_COLOR_HIGHLIGHT);
            mTextSize = a.GetDimensionPixelSize(Resource.Styleable.RVPIndicator_text_size,
                                                16);
            mIndicatorColor = a.GetColor(Resource.Styleable.RVPIndicator_indicator_color,
                                         D_INDICATOR_COLOR);
            mIndicatorStyle = a.GetInt(Resource.Styleable.RVPIndicator_indicator_style,
                                       STYLE_LINE);

            Drawable drawable = a
                                .GetDrawable(Resource.Styleable.RVPIndicator_indicator_src);

            if (drawable != null)
            {
                if (drawable is BitmapDrawable)
                {
                    mBitmap = ((BitmapDrawable)drawable).Bitmap;
                }
                else if (drawable is NinePatchDrawable)
                {
                    // .9图处理
                    Bitmap bitmap = Bitmap.CreateBitmap(
                        drawable.IntrinsicWidth,
                        drawable.IntrinsicHeight, Bitmap.Config.Argb8888);
                    Canvas canvas = new Canvas(bitmap);
                    drawable.SetBounds(0, 0, canvas.Width, canvas.Height);
                    drawable.Draw(canvas);
                    mBitmap = bitmap;
                }
            }
            else
            {
                mBitmap = BitmapFactory.DecodeResource(Resources,
                                                       Resource.Drawable.heart_love);
            }

            a.Recycle();

            /**
             * 设置画笔
             */
            mPaint           = new Paint();
            mPaint.AntiAlias = (true);
            mPaint.Color     = new Color(mIndicatorColor);
            mPaint.SetStyle(Style.Fill);
        }
Пример #6
0
        public ViewLayoutParams(Context c, IAttributeSet attrs) : base(c, attrs)
        {
            TypedArray ta = c.ObtainStyledAttributes(attrs, Resource.Styleable.DragLayout_Layout);

            this.Layer   = ta.GetInt(Resource.Styleable.DragLayout_Layout_layout_layer, LAYER_NONE);
            this.Gravity = (GravityFlags)ta.GetInt(Resource.Styleable.DragLayout_Layout_android_layout_gravity, (int)GravityFlags.NoGravity);
            ta.Recycle();
        }
Пример #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);
 }
Пример #8
0
        public XLHRatingBar(Context context, IAttributeSet attrs) : base(context, attrs)
        {
            TypedArray typedArray = context.ObtainStyledAttributes(attrs, Resource.Styleable.XlHRatingBar);

            countNum       = typedArray.GetInt(Resource.Styleable.XlHRatingBar_starCount, 5);
            countSelected  = typedArray.GetInt(Resource.Styleable.XlHRatingBar_countSelected, 0);
            canEdit        = typedArray.GetBoolean(Resource.Styleable.XlHRatingBar_canEdit, false);
            differentSize  = typedArray.GetBoolean(Resource.Styleable.XlHRatingBar_differentSize, false);
            widthAndHeight = typedArray.GetDimension(Resource.Styleable.XlHRatingBar_widthAndHeight, ScreenUtils.dpToPxInt(0));
            dividerWidth   = typedArray.GetDimension(Resource.Styleable.XlHRatingBar_dividerWidth, ScreenUtils.dpToPxInt(0));
            stateResId     = typedArray.GetResourceId(Resource.Styleable.XlHRatingBar_stateResId, -1);
            initView();
        }
Пример #9
0
        private void InitAttrs(Context context, IAttributeSet attrs, int defStyleAttr)
        {
            TypedArray attributes = context.ObtainStyledAttributes(attrs, Resource.Styleable.NumericEditText, defStyleAttr, 0);

            try
            {
                MaxDigitsBeforeDecimal = attributes.GetInt(Resource.Styleable.NumericEditText_maxDigitsBeforeDecimal, DefaultDigitsBeforeDecimal);
                MaxDigitsAfterDecimal  = attributes.GetInt(Resource.Styleable.NumericEditText_maxDigitsAfterDecimal, DefaultDigitsAfterDecimal);
            } finally
            {
                attributes.Recycle();
            }
        }
Пример #10
0
        public SwipeFrameLayout(Context context, IAttributeSet attrs, int defStyleAttr, int defStyleRes)
            : base(context, attrs, defStyleAttr, defStyleRes)
        {
            if (attrs != null)
            {
                TypedArray typedArray = context.ObtainStyledAttributes(attrs, Resource.Styleable.SwipeFrameLayout);

                SwipeLeftIndex  = typedArray.GetInt(Resource.Styleable.SwipeFrameLayout_SwipeLeftIndex, -1);
                SwipeRightIndex = typedArray.GetInt(Resource.Styleable.SwipeFrameLayout_SwipeRightIndex, -1);

                typedArray.Recycle();
            }
        }
Пример #11
0
        public SliderLayout(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle)
        {
            mh = new HandlerAnonymousInnerClassHelper(this);
            var _PresetIndicatorsToViewIdAccordance = new Dictionary <PresetIndicators, int>
            {
                { PresetIndicators.Center_Bottom, R.Id.default_center_bottom_indicator },
                { PresetIndicators.Right_Bottom, R.Id.default_bottom_right_indicator },
                { PresetIndicators.Left_Bottom, R.Id.default_bottom_left_indicator },
                { PresetIndicators.Center_Top, R.Id.default_center_top_indicator },
                { PresetIndicators.Right_Top, R.Id.default_center_top_right_indicator },
                { PresetIndicators.Left_Top, R.Id.default_center_top_left_indicator }
            };

            mContext = context;
            LayoutInflater.From(context).Inflate(R.Layout.slider_layout, this, true);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final android.content.res.TypedArray attributes = context.getTheme().obtainStyledAttributes(attrs,R.styleable.SliderLayout, defStyle,0);
            TypedArray attributes = context.Theme.ObtainStyledAttributes(attrs, R.Styleable.SliderLayout, defStyle, 0);

            mTransformerSpan = attributes.GetInteger(R.Styleable.SliderLayout_pager_animation_span, 1100);
            mTransformerId   = attributes.GetInt(R.Styleable.SliderLayout_pager_animation, Transformer.Default.Ordinal());
            mAutoCycle       = attributes.GetBoolean(R.Styleable.SliderLayout_auto_cycle, true);
            int visibility = attributes.GetInt(R.Styleable.SliderLayout_indicator_visibility, 0);

            foreach (IndicatorVisibility v in Enum.GetValues(typeof(IndicatorVisibility)))
            {
                if (v.Ordinal() == visibility)
                {
                    mIndicatorVisibility = v;
                    break;
                }
            }
            mSliderAdapter = new SliderAdapter(mContext);
            PagerAdapter wrappedAdapter = new InfinitePagerAdapter(mSliderAdapter);

            mViewPager         = FindViewById <InfiniteViewPager>(R.Id.daimajia_slider_viewpager);
            mViewPager.Adapter = wrappedAdapter;

            mViewPager.SetOnTouchListener(new OnTouchListenerAnonymousInnerClassHelper(this));

            attributes.Recycle();
            SetPresetIndicator(PresetIndicators.Center_Bottom);
            SetPresetTransformer(mTransformerId);
            setSliderTransformDuration(mTransformerSpan, null);
            IndicatorVisibility = mIndicatorVisibility;
            if (mAutoCycle)
            {
                startAutoCycle();
            }
        }
Пример #12
0
        void Initialize(Context context, IAttributeSet attrs)
        {
            TypedArray a = context.Theme.ObtainStyledAttributes(
                attrs,
                Resource.Styleable.squarelayout,
                0, 0);

            try {
                _rows = a.GetInt(Resource.Styleable.squarelayout_rows, 0);
                _cols = a.GetInt(Resource.Styleable.squarelayout_cols, 0);
            } finally {
                a.Recycle();
            }
        }
        public FixedAspectRatioFrameLayout(Context context, IAttributeSet attrs = null, int defStyle = 0)
            : base(context, attrs, defStyle)
        {
            TypedArray a = context.Theme.ObtainStyledAttributes(attrs, Resource.Styleable.FixedAspectFrameLayout, 0, 0);

            try
            {
                XRatio = a.GetInt(Resource.Styleable.FixedAspectFrameLayout_xRatio, DEFAULT_XRATIO);
                YRatio = a.GetInt(Resource.Styleable.FixedAspectFrameLayout_yRatio, DEFAULT_YRATIO);
            }
            finally
            {
                a.Recycle();
            }
        }
Пример #14
0
        public BoundedFrameLayout(Context context, IAttributeSet attrs = null, int defStyle = 0)
            : base(context, attrs, defStyle)
        {
            TypedArray a = context.Theme.ObtainStyledAttributes(attrs, Resource.Styleable.BoundedFrameLayout, 0, 0);

            try
            {
                boundedWidth  = a.GetInt(Resource.Styleable.BoundedFrameLayout_bounded_width, 0);
                boundedHeight = a.GetInt(Resource.Styleable.BoundedFrameLayout_bounded_height, 0);
            }
            finally
            {
                a.Recycle();
            }
        }
Пример #15
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();
        }
        public void ApplyStylableAttributes(Context context, TypedArray a, int[] styleableRes)
        {
            if (styleableRes == Resource.Styleable.RightAngleTriangle)
            {
                if (a.HasValue(Resource.Styleable.RightAngleTriangle_rightAnglePosition))
                {
                    RightAnglePosition = (RightAnglePosition)a.GetInt(Resource.Styleable.RightAngleTriangle_rightAnglePosition, 0);
                }

                if (a.HasValue(Resource.Styleable.RightAngleTriangle_fillColor))
                {
                    FillColor = a.GetColor(Resource.Styleable.RightAngleTriangle_fillColor, Color.White);
                }

                if (a.HasValue(Resource.Styleable.RightAngleTriangle_borderWidth))
                {
                    var borderWidth = a.GetDimensionPixelSize(Resource.Styleable.RightAngleTriangle_borderWidth, 0);
                    BorderThicknessPx = borderWidth > 0 ? borderWidth : 0;
                }

                if (a.HasValue(Resource.Styleable.RightAngleTriangle_borderColor))
                {
                    BorderColor = a.GetColor(Resource.Styleable.RightAngleTriangle_borderColor, Color.Transparent);
                }
            }
        }
Пример #17
0
        private void init(IAttributeSet attrs)
        {
            TypedArray typedArray = Context.ObtainStyledAttributes(attrs, Resource.Styleable.timeline_style);

            mMarker          = typedArray.GetDrawable(Resource.Styleable.timeline_style_marker);
            mStartLine       = typedArray.GetDrawable(Resource.Styleable.timeline_style_line);
            mEndLine         = typedArray.GetDrawable(Resource.Styleable.timeline_style_line);
            mMarkerSize      = typedArray.GetDimensionPixelSize(Resource.Styleable.timeline_style_markerSize, Utils.dpToPx(20, mContext));
            mLineSize        = typedArray.GetDimensionPixelSize(Resource.Styleable.timeline_style_lineSize, Utils.dpToPx(2, mContext));
            mLineOrientation = typedArray.GetInt(Resource.Styleable.timeline_style_lineOrientation, 1);
            mLinePadding     = typedArray.GetDimensionPixelSize(Resource.Styleable.timeline_style_linePadding, 0);
            mMarkerInCenter  = typedArray.GetBoolean(Resource.Styleable.timeline_style_markerInCenter, true);
            typedArray.Recycle();

            if (mMarker == null)
            {
                mMarker = mContext.Resources.GetDrawable(Resource.Drawable.marker);
            }

            if (mStartLine == null && mEndLine == null)
            {
                mStartLine = new ColorDrawable(mContext.Resources.GetColor(Android.Resource.Color.DarkerGray));
                mEndLine   = new ColorDrawable(mContext.Resources.GetColor(Android.Resource.Color.DarkerGray));
            }
        }
        public BottomSheet4StateBehaviour(Context context, IAttributeSet attrs) : base(context, attrs)
        {
            using (TypedArray a = context.ObtainStyledAttributes(attrs, Resource.Styleable.BottomSheetBehavior_Layout))
            {
                PeekHeight = a.GetDimensionPixelSize(Resource.Styleable.BottomSheetBehavior_Layout_behavior_peekHeight, 0);

                Hideable = a.GetBoolean(Resource.Styleable.BottomSheetBehavior_Layout_behavior_hideable, false);
            }

            /**
             * Getting the anchorPoint...
             */
            AnchorPoint = DefaultAnchorPoint > PeekHeight ? DefaultAnchorPoint : 0;
            Collapsible = true;


            using (TypedArray a1 = context.ObtainStyledAttributes(attrs, Resource.Styleable.CustomBottomSheetBehavior))
            {
                AnchorPoint = (int)a1.GetDimension(Resource.Styleable.CustomBottomSheetBehavior_anchorPoint, DefaultAnchorPoint);
//                _state = a1.GetInt(Resource.Styleable.CustomBottomSheetBehavior_defaultState, StateCollapsed);
                _state = a1.GetInt(Resource.Styleable.CustomBottomSheetBehavior_defaultState, StateAnchorPoint);
            }

            ViewConfiguration configuration = ViewConfiguration.Get(context);

            _minimumVelocity = configuration.ScaledMinimumFlingVelocity;

            _dragCallback = new ViewDragHelperCallback(this);
        }
Пример #19
0
 public void GridViewParams(TypedArray paramTypedArray)
 {
     this.HorizontalSpacing = paramTypedArray.GetDimensionPixelSize(0, 4);
     this.VerticalSpacing   = paramTypedArray.GetDimensionPixelSize(1, 4);
     this.NumColumns        = paramTypedArray.GetInt(3, 10);
     this.ColumnWidth       = paramTypedArray.GetDimensionPixelSize(2, 48);
 }
        /**
         * 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;
        }
Пример #21
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);
        }
Пример #22
0
 private void ApplyUnits(TypedArray attrs, int attributeIndex)
 {
     if (attrs.HasValue(attributeIndex))
     {
         _timeUnits = attrs.GetInt(attributeIndex, 0);
     }
 }
Пример #23
0
 public void GridViewParams(TypedArray paramTypedArray)
 {
     HorizontalSpacing = paramTypedArray.GetDimensionPixelSize(0, horizontalSpacing);
     VerticalSpacing   = paramTypedArray.GetDimensionPixelSize(1, verticalSpacing);
     NumColumns        = paramTypedArray.GetInt(3, numColumns);
     ColumnWidth       = paramTypedArray.GetDimensionPixelSize(2, columnWidth);
 }
        protected override void UseStyleAttributes(TypedArray attrs)
        {
            var titleText       = attrs.GetString(Resource.Styleable.SingleLineIconWithTextView_textForTitle);
            var titleTextColor  = attrs.GetColor(Resource.Styleable.SingleLineIconWithTextView_textColorForTitle, -1);
            var titleTextSize   = attrs.GetDimension(Resource.Styleable.SingleLineIconWithTextView_textSizeForTitle, -1);
            var titleTextStyle  = attrs.GetInt(Resource.Styleable.SingleLineIconWithTextView_textStyleForTitle, (int)Enum.ToObject(typeof(TypefaceStyle), TypefaceStyle.Normal));
            var titleTypeface   = attrs.GetInt(Resource.Styleable.SingleLineIconWithTextView_typefaceForTitle, 0);
            var titleFontFamily = attrs.GetString(Resource.Styleable.SingleLineIconWithTextView_fontFamilyForTitle);
            var iconSrc         = attrs.GetDrawable(Resource.Styleable.SingleLineIconWithTextView_iconSrc);
            var iconTint        = attrs.GetColor(Resource.Styleable.SingleLineIconWithTextView_iconTint, -1);

            attrs.Recycle();

            PrepareTextViewWithAttrValues(viewTitle, titleText, titleTextColor, titleTextSize, titleTextStyle, titleTypeface, titleFontFamily);
            PrepareIconViewWithAttrValues(iconSrc, iconTint);
        }
Пример #25
0
        public PresetsLayout(Context context, IAttributeSet attrs) : base(context, attrs)
        {
            ctx = context;
            TypedArray a = context.ObtainStyledAttributes(attrs, Resource.Styleable.PresetsLayout);

            _presets = a.GetInteger(Resource.Styleable.PresetsLayout_Presets, 1);
            _columns = a.GetInt(Resource.Styleable.PresetsLayout_Columns, 1);
            a.Recycle();

            ViewTreeObserver vto = this.ViewTreeObserver;

            vto.GlobalLayout += (sender, args) =>
            {
                _columnWidth = this.Width / _columns;
                int _rows = (int)Math.Ceiling((double)_presets / (double)_columns);
                _rowHeight = this.Height / _rows;
                _rowHeight = Math.Min(_rowHeight, _columnWidth);
                _padding   = this.Height - (_rowHeight * _rows);
                _padding  /= 2;
                Invalidate();
            };

            green = Resources.GetDrawable(Resource.Drawable.bol_green);
            white = Resources.GetDrawable(Resource.Drawable.bol_white);

            textPaint           = new Paint();
            textPaint.TextSize  = Resources.GetDimensionPixelSize(Resource.Dimension.PresetFontSize);
            textPaint.TextAlign = Paint.Align.Center;
            textPaint.SetTypeface(Typeface.CreateFromAsset(ctx.Assets, "robotastic.ttf"));
            _selectedPreset = 1;
        }
Пример #26
0
        public BlurringView(Context context, IAttributeSet attrs) : base(context, attrs)
        {
            Resources res = Resources;
            int       defaultBlurRadius       = res.GetInteger(Resource.Integer.default_blur_radius);
            int       defaultDownsampleFactor = res.GetInteger(Resource.Integer.default_downsample_factor);
            Color     defaultOverlayColor     = res.GetColor(Resource.Color.default_overlay_color);

            initializeRenderScript(context);

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

            setBlurRadius(a.GetInt(Resource.Styleable.PxBlurringView_blurRadius, defaultBlurRadius));
            setDownsampleFactor(a.GetInt(Resource.Styleable.PxBlurringView_downsampleFactor,
                                         defaultDownsampleFactor));
            setOverlayColor(a.GetColor(Resource.Styleable.PxBlurringView_overlayColor, defaultOverlayColor));
            a.Recycle();
        }
Пример #27
0
        public PinWidget(Context context, IAttributeSet attribs, int defStyleAttr) : base(context, attribs, defStyleAttr)
        {
            ShouldRedraw      = false;
            this.FillViewport = true;
            ScrollBarStyle    = ScrollbarStyles.OutsideInset;

            TypedArray array = context.ObtainStyledAttributes(attribs, Resource.Styleable.PinView);

            var method = array.GetString(Resource.Styleable.PinView_onPinCompleted);

            PinListener = new PrivatePinListener(method, this);

            DigitCount = (uint)array.GetInt(Resource.Styleable.PinView_digitCount, PinDefaults.DIGIT_COUNT);

            DisplayMetrics metrics = Resources.DisplayMetrics;

            // Digit dimensions
            DigitWidth   = array.GetDimensionPixelSize(Resource.Styleable.PinView_digitWidth, (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, PinDefaults.DIGIT_WIDTH, metrics));
            DigitHeight  = array.GetDimensionPixelSize(Resource.Styleable.PinView_digitHeight, (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, PinDefaults.DIGIT_HEIGHT, metrics));
            DigitSpacing = array.GetDimensionPixelSize(Resource.Styleable.PinView_digitSpacing, (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, PinDefaults.DIGIT_SPACING, metrics));
            TextSize     = array.GetDimensionPixelSize(Resource.Styleable.PinView_textSize, (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, PinDefaults.TEXT_SIZE, metrics));

            TypedValue resolvedColor = new TypedValue();

            Resources.Theme theme = context.Theme;

            // Colors
            theme.ResolveAttribute(Android.Resource.Attribute.TextColorPrimary, resolvedColor, true);
            TextColor = array.GetColor(Resource.Styleable.PinView_textColor,
                                       resolvedColor.ResourceId > 0 ? ContextCompat.GetColor(context, resolvedColor.ResourceId) : resolvedColor.Data);

            DigitBorderColor = array.GetColor(Resource.Styleable.PinView_borderColor, TextColor);

            resolvedColor = new TypedValue();
            theme.ResolveAttribute(Android.Resource.Attribute.ColorAccent, resolvedColor, true);
            AccentColor = array.GetColor(Resource.Styleable.PinView_accentColor,
                                         resolvedColor.ResourceId > 0 ? ContextCompat.GetColor(context, resolvedColor.ResourceId) : resolvedColor.Data);

            resolvedColor = new TypedValue();
            theme.ResolveAttribute(Android.Resource.Attribute.WindowBackground, resolvedColor, true);
            DigitBackgroundColor = array.GetColor(Resource.Styleable.PinView_digitBackgroundColor,
                                                  resolvedColor.ResourceId > 0 ? ContextCompat.GetColor(context, resolvedColor.ResourceId) : resolvedColor.Data);

            AccentHeight = (int)array.GetDimension(Resource.Styleable.PinView_accentHeight, TypedValue.ApplyDimension(ComplexUnitType.Dip, PinDefaults.ACCENT_HEIGHT, metrics));

            array.Recycle();

            _mainLayout    = new LinearLayout(Context);
            _pinInputField = new EditText(Context);

            var container = new FrameLayout(Context);

            container.AddView(_mainLayout);
            container.AddView(_pinInputField);
            this.AddView(container);

            ShouldRedraw = true;
        }
Пример #28
0
            public LayoutParams(Context c, IAttributeSet attrs)
                : base(c, attrs)
            {
                TypedArray a = c.ObtainStyledAttributes(attrs, Resource.Styleable.superslim_GridSLM);

                mNumColumns  = a.GetInt(Resource.Styleable.superslim_GridSLM_slm_grid_numColumns, AUTO_FIT);
                mColumnWidth = a.GetDimensionPixelSize(Resource.Styleable.superslim_GridSLM_slm_grid_columnWidth, -1);
                a.Recycle();
            }
Пример #29
0
        public void inititialize(Context context, IAttributeSet attrs, int defStyle)
        {
            mHandler = new SlidingHandler(this);
            TypedArray a = context.ObtainStyledAttributes(attrs, Resource.Styleable.MultiDirectionSlidingDrawer, defStyle, 0);

            int orientation = a.GetInt(Resource.Styleable.MultiDirectionSlidingDrawer_direction, ORIENTATION_BTT);

            mVertical       = (orientation == ORIENTATION_BTT || orientation == ORIENTATION_TTB);
            mBottomOffset   = (int)a.GetDimension(Resource.Styleable.MultiDirectionSlidingDrawer_bottomOffset, 0.0f);
            mTopOffset      = (int)a.GetDimension(Resource.Styleable.MultiDirectionSlidingDrawer_topOffset, 0.0f);
            mAllowSingleTap = a.GetBoolean(Resource.Styleable.MultiDirectionSlidingDrawer_allowSingleTap, true);
            mAnimateOnClick = a.GetBoolean(Resource.Styleable.MultiDirectionSlidingDrawer_animateOnClick, true);
            mInvert         = (orientation == ORIENTATION_TTB || orientation == ORIENTATION_LTR);

            int handleId = a.GetResourceId(Resource.Styleable.MultiDirectionSlidingDrawer_handle, 0);

            if (handleId == 0)
            {
                throw new Java.Lang.IllegalArgumentException("The handle attribute is required and must refer "
                                                             + "to a valid child.");
            }

            int contentId = a.GetResourceId(Resource.Styleable.MultiDirectionSlidingDrawer_content, 0);

            if (contentId == 0)
            {
                throw new Java.Lang.IllegalArgumentException("The content attribute is required and must refer "
                                                             + "to a valid child.");
            }

            if (handleId == contentId)
            {
                throw new Java.Lang.IllegalArgumentException("The content and handle attributes must refer "
                                                             + "to different children.");
            }
            mHandleId  = handleId;
            mContentId = contentId;

            float density = Resources.DisplayMetrics.Density;

            mTapThreshold         = (int)(TAP_THRESHOLD * density + 0.5f);
            mMaximumTapVelocity   = (int)(MAXIMUM_TAP_VELOCITY * density + 0.5f);
            mMaximumMinorVelocity = (int)(MAXIMUM_MINOR_VELOCITY * density + 0.5f);
            mMaximumMajorVelocity = (int)(MAXIMUM_MAJOR_VELOCITY * density + 0.5f);
            mMaximumAcceleration  = (int)(MAXIMUM_ACCELERATION * density + 0.5f);
            mVelocityUnits        = (int)(VELOCITY_UNITS * density + 0.5f);

            if (mInvert)
            {
                mMaximumAcceleration  = -mMaximumAcceleration;
                mMaximumMajorVelocity = -mMaximumMajorVelocity;
                mMaximumMinorVelocity = -mMaximumMinorVelocity;
            }

            a.Recycle();
            AlwaysDrawnWithCacheEnabled = false;
        }
        private void Init(Context context, IAttributeSet attrs)
        {
            TypedArray ta = context.ObtainStyledAttributes(attrs, Resource.Styleable.TriangleLabelView);

            this.topPadding    = ta.GetDimension(Resource.Styleable.TriangleLabelView_labelTopPadding, 7f.DpToPx(this.Context));
            this.centerPadding = ta.GetDimension(Resource.Styleable.TriangleLabelView_labelCenterPadding, 3f.DpToPx(this.Context));
            this.bottomPadding = ta.GetDimension(Resource.Styleable.TriangleLabelView_labelBottomPadding, 3f.DpToPx(this.Context));

            this.triangleBackgroundColor = ta.GetColor(Resource.Styleable.TriangleLabelView_backgroundColor, Color.ParseColor("#66000000"));
            this.primary.Color           = ta.GetColor(Resource.Styleable.TriangleLabelView_primaryTextColor, Color.White);
            this.secondary.Color         = ta.GetColor(Resource.Styleable.TriangleLabelView_secondaryTextColor, Color.White);

            this.primary.Size   = ta.GetDimension(Resource.Styleable.TriangleLabelView_primaryTextSize, 11f.SpToPx(this.Context));
            this.secondary.Size = ta.GetDimension(Resource.Styleable.TriangleLabelView_secondaryTextSize, 8f.SpToPx(this.Context));

            var primaryText = ta.GetString(Resource.Styleable.TriangleLabelView_primaryText);

            if (!string.IsNullOrEmpty(primaryText))
            {
                this.primary.Text = primaryText;
            }
            var secondaryText = ta.GetString(Resource.Styleable.TriangleLabelView_secondaryText);

            if (!string.IsNullOrEmpty(secondaryText))
            {
                this.secondary.Text = secondaryText;
            }

            this.primary.Style   = ta.GetInt(Resource.Styleable.TriangleLabelView_primaryTextStyle, 2);
            this.secondary.Style = ta.GetInt(Resource.Styleable.TriangleLabelView_secondaryTextStyle, 0);

            this.Corner = (Corner)ta.GetInt(Resource.Styleable.TriangleLabelView_corner, 1);

            ta.Recycle();

            this.primary.Initialize();
            this.secondary.Initialize();

            this.trianglePaint       = new Paint(PaintFlags.AntiAlias);
            this.trianglePaint.Color = this.triangleBackgroundColor;

            this.primary.ResetStatus();
            this.secondary.ResetStatus();
        }
Пример #31
0
 public void GridViewParams(TypedArray paramTypedArray)
 {
     this.HorizontalSpacing = paramTypedArray.GetDimensionPixelSize(0, 4);
     this.VerticalSpacing = paramTypedArray.GetDimensionPixelSize(1, 4);
     this.NumColumns = paramTypedArray.GetInt(3, 10);
     this.ColumnWidth = paramTypedArray.GetDimensionPixelSize(2, 48);
 }