Ejemplo n.º 1
0
        /// <summary>
        /// Initializes XML attributes.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="attrs"></param>
        private void Init(Context context, IAttributeSet attrs)
        {
            TypedArray array = null;

            try
            {
                if (attrs != null)
                {
                    array = context.Theme.ObtainStyledAttributes(attrs, Resource.Styleable.DragToClose, 0, 0);

                    DraggableViewId      = array.GetResourceId(Resource.Styleable.DragToClose_draggableView, -1);
                    DraggableContainerId = array.GetResourceId(Resource.Styleable.DragToClose_draggableContainer, -1);
                    FinishActivity       = array.GetBoolean(Resource.Styleable.DragToClose_finishActivity, true);
                    CloseOnClick         = array.GetBoolean(Resource.Styleable.DragToClose_closeOnClick, false);
                    if (DraggableViewId == -1 || DraggableContainerId == -1)
                    {
                        throw new IllegalArgumentException("draggableView and draggableContainer attributes are required.");
                    }
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
            finally
            {
                array?.Recycle();
            }
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        private void Init(Context context = null, IAttributeSet attrs = null)
        {
            var backgroundSrc = Resource.Drawable.journey7;
            var thumbnailSrc  = Resource.Drawable.journey7;
            var title         = string.Empty;

            if (attrs != null && context != null)
            {
                TypedArray array = context.ObtainStyledAttributes(attrs, Resource.Styleable.PersonHeader);
                backgroundSrc = array.GetResourceId(Resource.Styleable.PersonHeader_backgroundSrc, backgroundSrc);
                thumbnailSrc  = array.GetResourceId(Resource.Styleable.PersonHeader_thumbnailSrc, thumbnailSrc);
                title         = array.GetString(Resource.Styleable.PersonHeader_title);
            }


            //////////////////////////////////////////////
            if (context != null)
            {
                Inflate(context, Resource.Layout.PersonHeader, this);
                _background = FindViewById <BlurredImage>(Resource.Id.PersonHeaderBackgorund);
                _thumbnail  = FindViewById <ImageView>(Resource.Id.PersonHeaderThumbnail);
                _title      = FindViewById <TextView>(Resource.Id.PersonHeaderTitle);

                _background.SetImageResource(backgroundSrc);
                _thumbnail.SetImageResource(thumbnailSrc);
                _thumbnail.ClipToOutline = true;
                _title.Text = title;
            }
        }
Ejemplo n.º 4
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();
        }
Ejemplo n.º 5
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;
        }
        void Init(IAttributeSet attrs)
        {
            _headerContainer  = new FrameLayout(Context);
            _zoomContainer    = new FrameLayout(Context);
            _contentContainer = new FrameLayout(Context);

            _rootContainer             = new LinearLayout(Context);
            _rootContainer.Orientation = Android.Widget.Orientation.Vertical;

            if (attrs != null)
            {
                LayoutInflater layoutInflater = LayoutInflater.From(Context);
                //初始化状态View
                TypedArray a = Context.ObtainStyledAttributes(attrs, Resource.Styleable.PullToZoomScrollView);

                int zoomViewResId = a.GetResourceId(Resource.Styleable.PullToZoomScrollView_scrollZoomView, 0);
                if (zoomViewResId > 0)
                {
                    _zoomView = layoutInflater.Inflate(zoomViewResId, null, false);
                    _zoomContainer.AddView(_zoomView);
                    _headerContainer.AddView(_zoomContainer);
                }

                int headViewResId = a.GetResourceId(Resource.Styleable.PullToZoomScrollView_scrollHeadView, 0);
                if (headViewResId > 0)
                {
                    _headView = layoutInflater.Inflate(headViewResId, null, false);
                    _headerContainer.AddView(_headView);
                }
                int contentViewResId = a.GetResourceId(Resource.Styleable.PullToZoomScrollView_scrollContentView, 0);
                if (contentViewResId > 0)
                {
                    _contentView = layoutInflater.Inflate(contentViewResId, null, false);
                    _contentContainer.AddView(_contentView);
                }

                a.Recycle();
            }

            DisplayMetrics localDisplayMetrics = new DisplayMetrics();

            ((Activity)Context).WindowManager.DefaultDisplay.GetMetrics(localDisplayMetrics);
            _screenHeight    = localDisplayMetrics.HeightPixels;
            _zoomWidth       = localDisplayMetrics.WidthPixels;
            _scalingRunnable = new ScalingRunnable(this);

            _rootContainer.AddView(_headerContainer);
            _rootContainer.AddView(_contentContainer);

            _rootContainer.SetClipChildren(false);
            _headerContainer.SetClipChildren(false);

            AddView(_rootContainer);
        }
        public EffectsAdapter(Context context)
        {
            MInflater = LayoutInflater.From(context);

            Resources res = context.Resources;

            MTitles = res.GetStringArray(Resource.Array.effects_name);

            string[] actionsHtml = res.GetStringArray(Resource.Array.effects_actions_html);
            string[] contentHtml = res.GetStringArray(Resource.Array.effects_content_html);

            MHtmls = new string[][] { actionsHtml, contentHtml };

            TypedArray layoutsArray = res.ObtainTypedArray(Resource.Array.effect_layouts);

            int count = layoutsArray.Length();

            MLayouts = new int[count];

            for (int i = 0; i < count; ++i)
            {
                MLayouts[i] = layoutsArray.GetResourceId(i, 0);
            }

            layoutsArray.Recycle();
        }
        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();
                }
            }
        }
Ejemplo n.º 9
0
        public void SetEffects(Context context, int resId)
        {
            string resourceType = context.Resources.GetResourceTypeName(resId);

            if (!resourceType.Equals("array"))
            {
                Animation anim = AnimationUtils.LoadAnimation(context, resId);
                SetEffects(anim);

                return;
            }

            TypedArray effects = context.Resources.ObtainTypedArray(resId);

            int count = effects.Length();
            int size  = System.Math.Min(EFFECTS_COUNT, count);

            for (int i = 0; i < size; ++i)
            {
                int id = effects.GetResourceId(i, -1);
                if (id > 0)
                {
                    Animation anim = AnimationUtils.LoadAnimation(context, id);
                    mEffects[i] = new Effect(anim);
                }
            }
            effects.Recycle();
        }
Ejemplo n.º 10
0
        private void Init(Context context, IAttributeSet attrs)
        {
            try
            {
                if (attrs != null)
                {
                    TypedArray typedArray = context.ObtainStyledAttributes(attrs, Resource.Styleable.RecordButton);

                    int imageResource = typedArray.GetResourceId(Resource.Styleable.RecordButton_mic_icon, -1);

                    if (imageResource != -1)
                    {
                        SetTheImageResource(imageResource);
                    }

                    typedArray.Recycle();
                }

                ScaleAnim = new ScaleAnim(this);

                SetOnTouchListener(this);
                SetOnClickListener(this);
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Ejemplo n.º 11
0
        private void InitializeDrawerItems()
        {
            // add data
            var data = new List <DrawerListItemModel>();

            for (int i = 0; i < tiles.Length; i++)
            {
                data.Add(new DrawerListItemModel()
                {
                    Name  = tiles[i],
                    Image = drawer_items_icons.GetResourceId(i, -1)
                });
            }

            // add header
            var header = new DrawerHeaderModel()
            {
                AppName = GetString(Resource.String.app_name)
            };

            drawer_items = new DrawerItemModel()
            {
                Data   = data,
                Header = header
            };
        }
Ejemplo n.º 12
0
        public CenteredToolbar(Context context, IAttributeSet attrs, int defStyleAttr) : base(context, attrs, defStyleAttr)
        {
            titleView = new TextView(context);

            int textAppearanceStyleResId;
            int textColorResId;

            TypedArray a = context.Theme.ObtainStyledAttributes(attrs,
                                                                new int[] { Resource.Attribute.titleTextAppearance }, defStyleAttr, 0);
            TypedArray b = context.Theme.ObtainStyledAttributes(attrs,
                                                                new int[] { Resource.Attribute.titleTextColor }, defStyleAttr, 0);

            try
            {
                textAppearanceStyleResId = a.GetResourceId(0, 0);
                textColorResId           = b.GetResourceId(0, 0);
            }
            finally
            {
                a.Recycle();
            }
            if (textAppearanceStyleResId > 0)
            {
                titleView.SetTextAppearance(context, textAppearanceStyleResId);
                titleView.SetTextColor(Resources.GetColor(textColorResId));
            }

            AddView(titleView, new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent));
        }
Ejemplo n.º 13
0
        private void InitView()
        {
            parentLayout = FindViewById <RelativeLayout>(Resource.Id.demo_parent);
            imageView    = FindViewById <ImageView>(Resource.Id.demo_image);
            listView     = FindViewById <ListView>(Resource.Id.demo_list);
            myView       = FindViewById <MyView>(Resource.Id.demo_myview);
            button       = FindViewById <Button>(Resource.Id.demo_button);

            button.Click += delegate
            { Toast.MakeText(this, "Button onClick", ToastLength.Short).Show(); };
            TypedArray ar  = Resources.ObtainTypedArray(Resource.Array.imgArray);
            int        len = ar.Length();

            resids = new List <int>();
            for (int i = 0; i < len; i++)
            {
                resids.Add(ar.GetResourceId(i, 0));
            }

            InitSeekBar();
            InitToggleButton();
            InitToolbar();
            InitDrawerLayout();
            RefreshDate();
        }
Ejemplo n.º 14
0
        public AHBottomNavigationBehavior(Context context, IAttributeSet attrs) : base(context, attrs)
        {
            TypedArray a = context.ObtainStyledAttributes(attrs, Resource.Styleable.AHBottomNavigationBehavior_Params);

            mTabLayoutId = a.GetResourceId(Resource.Styleable.AHBottomNavigationBehavior_Params_tabLayoutId, View.NoId);
            a.Recycle();
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PagerSlidingTabStrip"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="attrs">The attributes from xml.</param>
        /// <param name="defStyle">The default style.</param>
        public PagerSlidingTabStrip(Context context, IAttributeSet attrs, int defStyle)
            : base(context, attrs, defStyle)
        {
            HorizontalScrollBarEnabled = false;
            FillViewport = true;
            SetWillNotDraw(false);
            _tabsContainer                  = new LinearLayout(context);
            _tabsContainer.Orientation      = Android.Widget.Orientation.Horizontal;
            _tabsContainer.LayoutParameters = new ViewGroup.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
            AddView(_tabsContainer);

            DisplayMetrics dm = Resources.DisplayMetrics;

            _scrollOffset      = Convert.ToInt32(TypedValue.ApplyDimension(ComplexUnitType.Dip, _scrollOffset, dm));
            _indicatorHeight   = Convert.ToInt32(TypedValue.ApplyDimension(ComplexUnitType.Dip, _indicatorHeight, dm));
            _underlineHeight   = Convert.ToInt32(TypedValue.ApplyDimension(ComplexUnitType.Dip, _underlineHeight, dm));
            _tabDividerPadding = Convert.ToInt32(TypedValue.ApplyDimension(ComplexUnitType.Dip, _tabDividerPadding, dm));
            _tabPadding        = Convert.ToInt32(TypedValue.ApplyDimension(ComplexUnitType.Dip, _tabPadding, dm));
            _dividerWidth      = Convert.ToInt32(TypedValue.ApplyDimension(ComplexUnitType.Dip, _dividerWidth, dm));
            _tabTextSize       = Convert.ToInt32(TypedValue.ApplyDimension(ComplexUnitType.Dip, _tabTextSize, dm));

            // get system attrs (android:textSize and android:textColor)

            TypedArray a = context.ObtainStyledAttributes(attrs, ATTRS);

            _tabTextSize  = a.GetDimensionPixelSize(0, _tabTextSize);
            _tabTextColor = a.GetColor(1, _tabTextColor);

            a.Recycle();

            // get custom attrs

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

            _indicatorColor     = a.GetColor(Resource.Styleable.PagerSlidingTabStrip_indicatorColor, _indicatorColor);
            _underlineColor     = a.GetColor(Resource.Styleable.PagerSlidingTabStrip_underlineColor, _underlineColor);
            _dividerColor       = a.GetColor(Resource.Styleable.PagerSlidingTabStrip_dividerColor, _dividerColor);
            _indicatorHeight    = a.GetDimensionPixelSize(Resource.Styleable.PagerSlidingTabStrip_indicatorHeight, _indicatorHeight);
            _underlineHeight    = a.GetDimensionPixelSize(Resource.Styleable.PagerSlidingTabStrip_underlineHeight, _underlineHeight);
            _tabDividerPadding  = a.GetDimensionPixelSize(Resource.Styleable.PagerSlidingTabStrip_tabDividerPadding, _tabDividerPadding);
            _tabPadding         = a.GetDimensionPixelSize(Resource.Styleable.PagerSlidingTabStrip_tabPaddingLeftRight, _tabPadding);
            _tabBackgroundResId = a.GetResourceId(Resource.Styleable.PagerSlidingTabStrip_tabBackground, _tabBackgroundResId);
            _shouldExpand       = a.GetBoolean(Resource.Styleable.PagerSlidingTabStrip_shouldExpand, _shouldExpand);
            _scrollOffset       = a.GetDimensionPixelSize(Resource.Styleable.PagerSlidingTabStrip_scrollOffset, _scrollOffset);
            _tabTextAllCaps     = a.GetBoolean(Resource.Styleable.PagerSlidingTabStrip_tabTextAllCaps, _tabTextAllCaps);

            a.Recycle();

            _rectPaint           = new Paint();
            _rectPaint.AntiAlias = true;
            _rectPaint.SetStyle(Android.Graphics.Paint.Style.Fill);

            _dividerPaint             = new Paint();
            _dividerPaint.AntiAlias   = true;
            _dividerPaint.StrokeWidth = _dividerWidth;

            _defaultTabLayoutParams  = new LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.MatchParent);
            _expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MatchParent, 1.0f);
        }
Ejemplo n.º 16
0
 private void ApplyTextAppearance(Context context, TypedArray attrs, int attributeIndex, TextView[] targetViews)
 {
     int id = attrs.GetResourceId(attributeIndex, 0);
     if (id != 0)
     {
         ApplyTextAppearance(context, id, targetViews);
     }
 }
        void Init(Context context, IAttributeSet attrs)
        {
            SetGravity(GravityFlags.Center);

            ViewConfiguration config = ViewConfiguration.Get(context);

            _touchSlop = config.ScaledTouchSlop;

            DisplayMetrics localDisplayMetrics = new DisplayMetrics();

            ((Activity)Context).WindowManager.DefaultDisplay.GetMetrics(localDisplayMetrics);
            _screenHeight = localDisplayMetrics.HeightPixels;
            _screenWidth  = localDisplayMetrics.WidthPixels;

            // Refreshable View
            // By passing the attrs, we can add ListView/GridView params via XML
            _rootView = CreateRootView(context, attrs);

            if (attrs != null)
            {
                LayoutInflater layoutInflater = LayoutInflater.From(Context);
                TypedArray     a = Context.ObtainStyledAttributes(attrs, Resource.Styleable.PullToZoomView);

                int zoomViewResId = a.GetResourceId(Resource.Styleable.PullToZoomView_zoomView, 0);
                if (zoomViewResId > 0)
                {
                    _zoomView = layoutInflater.Inflate(zoomViewResId, null, false);
                }

                int headerViewResId = a.GetResourceId(Resource.Styleable.PullToZoomView_headerView, 0);
                if (headerViewResId > 0)
                {
                    _headerView = layoutInflater.Inflate(headerViewResId, null, false);
                }

                _isParallax = a.GetBoolean(Resource.Styleable.PullToZoomListView_isHeadParallax, true);

                // Let the derivative classes have a go at handling attributes, then
                // recycle them...

                ((IPullToZoom <T>) this).HandleStyledAttributes(a);
                a.Recycle();
            }
            AddView(_rootView, ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
        }
Ejemplo n.º 18
0
        public ActionBarView(Context context, IAttributeSet attrs)
            : base(context, attrs)
        {
            SetMinimumWidth(0);
            SetMinimumHeight(0);
            Visibility = ViewStates.Gone;
            TypedArray typedArray = Context.ObtainStyledAttributes(attrs, Resource.Styleable.ActionBar);

            try
            {
                _resourceId   = typedArray.GetResourceId(Resource.Styleable.ActionBar_ActionBarTemplate, int.MinValue);
                _tabContentId = typedArray.GetResourceId(Resource.Styleable.ActionBar_TabContentId, int.MinValue);
            }
            finally
            {
                typedArray.Recycle();
            }
        }
Ejemplo n.º 19
0
        public ImageAdapter(Context c)
        {
            mContext = c;
            // See res/values/attrs.xml for the <declare-styleable> that defines
            // Gallery1.
            TypedArray a = mContext.ObtainStyledAttributes(Resource.Styleable.Gallery1);

            mGalleryItemBackground = a.GetResourceId(Resource.Styleable.Gallery1_android_galleryItemBackground, 0);
            a.Recycle();

            mDensity = c.Resources.DisplayMetrics.Density;
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Last but not least, try to pull the Font Path from the Theme, which is defined.
        /// </summary>
        /// <returns>null if no theme or attribute defined.</returns>
        /// <param name="context">Activity Context.</param>
        /// <param name="styleAttrId">Theme style id.</param>
        /// <param name="subStyleAttrId">the sub style from the theme to look up after the first style.</param>
        /// <param name="attributeId">if -1 returns null.</param>
        internal static string PullFontPathFromTheme(Context context, int styleAttrId, int subStyleAttrId, int[] attributeId)
        {
            if (styleAttrId == -1 || attributeId == null)
            {
                return(null);
            }

            Android.Content.Res.Resources.Theme theme = context.Theme;
            var value = new TypedValue();

            theme.ResolveAttribute(styleAttrId, value, true);
            int        subStyleResId    = -1;
            TypedArray parentTypedArray = theme.ObtainStyledAttributes(value.ResourceId, new int[] { subStyleAttrId });

            try
            {
                subStyleResId = parentTypedArray.GetResourceId(0, -1);
            }
            catch (Exception)
            {
                // Failed for some reason.
                return(null);
            }
            finally
            {
                parentTypedArray.Recycle();
            }

            if (subStyleResId == -1)
            {
                return(null);
            }
            TypedArray subTypedArray = context.ObtainStyledAttributes(subStyleResId, attributeId);

            if (subTypedArray != null)
            {
                try
                {
                    return(subTypedArray.GetString(0));
                }
                catch (Exception)
                {
                    // Failed for some reason.
                    return(null);
                }
                finally
                {
                    subTypedArray.Recycle();
                }
            }
            return(null);
        }
Ejemplo n.º 21
0
        int[] GetResourceIdArray(int arrayResId)
        {
            TypedArray ar  = Context.Resources.ObtainTypedArray(arrayResId);
            int        len = ar.Length();

            int[] resIds = new int[len];
            for (int i = 0; i < len; i++)
            {
                resIds[i] = ar.GetResourceId(i, 0);
            }
            ar.Recycle();
            return(resIds);
        }
Ejemplo n.º 22
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();
        }
Ejemplo n.º 23
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            View view = convertView;

            if (view == null) // no view to re-use, create new
            {
                view = context.LayoutInflater.Inflate(Resource.Layout.side_menu_options_item, null);
            }
            view.FindViewById <ImageView>(Resource.Id.item_icon).SetImageResource(Icons.GetResourceId(position, -1));
            view.FindViewById <TextView>(Resource.Id.item_title).Text = Options[position];

            return(view);
        }
Ejemplo n.º 24
0
        private static int?ReadAttributeValueId(TypedArray typedArray, int requiredAttributeId, View view, Type viewType, string attachedPropertyName)
        {
            var result = typedArray.GetResourceId(requiredAttributeId, int.MinValue);

            if (result == int.MinValue)
            {
                return(null);
            }
            if (attachedPropertyName != null)
            {
                BindingServiceProvider.MemberProvider.GetBindingMember(viewType, attachedPropertyName, false, false)?.SetSingleValue(view, result);
            }
            return(result);
        }
Ejemplo n.º 25
0
        protected void initAttrs(IAttributeSet attrs)
        {
            TypedArray a = Context.ObtainStyledAttributes(attrs, Resource.Styleable.superrecyclerview);

            try
            {
                mClipToPadding  = a.GetBoolean(Resource.Styleable.superrecyclerview_recyclerClipToPadding, false);
                mPadding        = (int)a.GetDimension(Resource.Styleable.superrecyclerview_recyclerPadding, -1.0f);
                mPaddingTop     = (int)a.GetDimension(Resource.Styleable.superrecyclerview_recyclerPaddingTop, 0.0f);
                mPaddingBottom  = (int)a.GetDimension(Resource.Styleable.superrecyclerview_recyclerPaddingBottom, 0.0f);
                mPaddingLeft    = (int)a.GetDimension(Resource.Styleable.superrecyclerview_recyclerPaddingLeft, 0.0f);
                mPaddingRight   = (int)a.GetDimension(Resource.Styleable.superrecyclerview_recyclerPaddingRight, 0.0f);
                mScrollbarStyle = a.GetInteger(Resource.Styleable.superrecyclerview_scrollbarStyle, -1);
                mScrollbar      = a.GetInteger(Resource.Styleable.superrecyclerview_scrollbars, -1);

                mEmptyId    = a.GetResourceId(Resource.Styleable.superrecyclerview_layout_empty, 0);
                mProgressId = a.GetResourceId(Resource.Styleable.superrecyclerview_layout_progress, 0);
                mErrorId    = a.GetResourceId(Resource.Styleable.superrecyclerview_layout_error, Resource.Layout.common_net_error_view);
            }
            finally
            {
                a.Recycle();
            }
        }
Ejemplo n.º 26
0
        private static int?ReadAttributeValueId(Context context, IAttributeSet attrs, int[] groupId,
                                                int requiredAttributeId)
        {
            TypedArray typedArray = context.Theme.ObtainStyledAttributes(attrs, groupId, 0, 0);

            try
            {
                int result = typedArray.GetResourceId(requiredAttributeId, int.MinValue);
                return(result == int.MinValue ? (int?)null : result);
            }
            finally
            {
                typedArray.Recycle();
            }
        }
Ejemplo n.º 27
0
        private void HandleTypedArray(Context context, IAttributeSet attrs)
        {
            if (attrs == null)
            {
                return;
            }
            TypedArray typedArray = context.ObtainStyledAttributes(attrs, Resource.Styleable.Banner);

            mIndicatorWidth           = typedArray.GetDimensionPixelSize(Resource.Styleable.Banner_indicator_width, indicatorSize);
            mIndicatorHeight          = typedArray.GetDimensionPixelSize(Resource.Styleable.Banner_indicator_height, indicatorSize);
            mIndicatorMargin          = typedArray.GetDimensionPixelSize(Resource.Styleable.Banner_indicator_margin, BannerConfig.PADDING_SIZE);
            mIndicatorSelectedResId   = typedArray.GetResourceId(Resource.Styleable.Banner_indicator_drawable_selected, Resource.Drawable.gray_radius);
            mIndicatorUnselectedResId = typedArray.GetResourceId(Resource.Styleable.Banner_indicator_drawable_unselected, Resource.Drawable.white_radius);
            scaleType       = typedArray.GetInt(Resource.Styleable.Banner_image_scale_type, scaleType);
            delayTime       = typedArray.GetInt(Resource.Styleable.Banner_delay_time, BannerConfig.TIME);
            scrollTime      = typedArray.GetInt(Resource.Styleable.Banner_scroll_time, BannerConfig.DURATION);
            isAutoPlay      = typedArray.GetBoolean(Resource.Styleable.Banner_is_auto_play, BannerConfig.IS_AUTO_PLAY);
            titleBackground = typedArray.GetColor(Resource.Styleable.Banner_title_background, BannerConfig.TITLE_BACKGROUND);
            titleHeight     = typedArray.GetDimensionPixelSize(Resource.Styleable.Banner_title_height, BannerConfig.TITLE_HEIGHT);
            titleTextColor  = typedArray.GetColor(Resource.Styleable.Banner_title_textcolor, BannerConfig.TITLE_TEXT_COLOR);
            titleTextSize   = typedArray.GetDimensionPixelSize(Resource.Styleable.Banner_title_textsize, BannerConfig.TITLE_TEXT_SIZE);
            mLayoutResId    = typedArray.GetResourceId(Resource.Styleable.Banner_layout_id, mLayoutResId);
            typedArray.Recycle();
        }
Ejemplo n.º 28
0
        public Marker(Context context, IAttributeSet attrs, int defStyleAttr, String maxValue, int thumbSize, int separation)
            : base(context, attrs, defStyleAttr)
        {
            Visibility = ViewStates.Visible;

            DisplayMetrics displayMetrics = context.Resources.DisplayMetrics;
            TypedArray     a = context.ObtainStyledAttributes(attrs, Resource.Styleable.DiscreteSeekBar,
                                                              Resource.Attribute.discreteSeekBarStyle, Resource.Style.Widget_DiscreteSeekBar);

            int padding          = (int)(PADDING_DP * displayMetrics.Density) * 2;
            int textAppearanceId = a.GetResourceId(Resource.Styleable.DiscreteSeekBar_dsb_indicatorTextAppearance,
                                                   Resource.Style.Widget_DiscreteIndicatorTextAppearance);

            mNumber = new TextView(context);
            //Add some padding to this textView so the bubble has some space to breath
            mNumber.SetPadding(padding, 0, padding, 0);
            mNumber.SetTextAppearance(context, textAppearanceId);
            mNumber.Gravity = GravityFlags.Center;
            mNumber.Text    = maxValue;
            mNumber.SetMaxLines(1);
            mNumber.SetSingleLine(true);
            SeekBarCompat.SetTextDirection(mNumber, (int)TextDirectionLocale);
            mNumber.Visibility = ViewStates.Invisible;

            //add some padding for the elevation shadow not to be clipped
            //I'm sure there are better ways of doing this...
            SetPadding(padding, padding, padding, padding);

            ResetSizes(maxValue);

            mSeparation = separation;
            ColorStateList color = a.GetColorStateList(Resource.Styleable.DiscreteSeekBar_dsb_indicatorColor);

            mMarkerDrawable = new MarkerDrawable(color, thumbSize);
            mMarkerDrawable.SetCallback(this);
            mMarkerDrawable.SetMarkerListener(this);
            mMarkerDrawable.SetExternalOffset(padding);

            //Elevation for anroid 5+
            float elevation = a.GetDimension(Resource.Styleable.DiscreteSeekBar_dsb_indicatorElevation, ELEVATION_DP * displayMetrics.Density);

            ViewCompat.SetElevation(this, elevation);
            if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
            {
                SeekBarCompat.SetOutlineProvider(this, mMarkerDrawable);
            }
            a.Recycle();
        }
        /// <summary>
        /// Attaches the SlidingMenu to an entire Activity
        /// </summary>
        /// <param name="activity"> the Activity </param>
        /// <param name="slideStyle"> either SLIDING_CONTENT or SLIDING_WINDOW </param>
        /// <param name="actionbarOverlay"> whether or not the ActionBar is overlaid </param>
        public void AttachToActivity(Activity activity, int slideStyle, bool actionbarOverlay)
        {
            if (slideStyle != SLIDING_WINDOW && slideStyle != SLIDING_CONTENT)
            {
                throw new System.ArgumentException("slideStyle must be either SLIDING_WINDOW or SLIDING_CONTENT");
            }

            if (Parent != null)
            {
                throw new IllegalStateException("This SlidingMenu appears to already be attached");
            }

            // get the window background
            TypedArray a          = activity.Theme.ObtainStyledAttributes(new int[] { Android.Resource.Attribute.WindowBackground });
            int        background = a.GetResourceId(0, 0);

            a.Recycle();

            switch (slideStyle)
            {
            case SLIDING_WINDOW:
                mActionbarOverlay = false;
                ViewGroup decor      = (ViewGroup)activity.Window.DecorView;
                ViewGroup decorChild = (ViewGroup)decor.GetChildAt(0);
                // save ActionBar themes that have transparent assets
                decorChild.SetBackgroundResource(background);
                decor.RemoveView(decorChild);
                decor.AddView(this);
                SetContent(decorChild);
                break;

            case SLIDING_CONTENT:
                mActionbarOverlay = actionbarOverlay;
                // take the above view out of
                ViewGroup contentParent = (ViewGroup)activity.FindViewById(Android.Resource.Id.Content);
                View      content       = contentParent.GetChildAt(0);
                contentParent.RemoveView(content);
                contentParent.AddView(this);
                SetContent(content);
                // save people from having transparent backgrounds
                if (content.Background == null)
                {
                    content.SetBackgroundResource(background);
                }
                break;
            }
        }
Ejemplo n.º 30
0
        private void InitView(Context context, IAttributeSet attributeSet)
        {
            TypedArray attributes = context.Theme.ObtainStyledAttributes(attributeSet, Resource.Styleable.TemplateView, 0, 0);

            try
            {
                TemplateType = attributes.GetResourceId(Resource.Styleable.TemplateView_gnt_template_type, Resource.Layout.gnt_medium_template_view);
            }
            finally
            {
                attributes.Recycle();
            }

            LayoutInflater inflater = (LayoutInflater)context.GetSystemService(Context.LayoutInflaterService);

            inflater.Inflate(TemplateType, this);
        }
 private void InitializeAnimationDuration(TypedArray attributes)
 {
     int animationDuration =
         attributes.GetInteger(Resource.Styleable.expandable_selector_animation_duration,
             DEFAULT_ANIMATION_DURATION);
     int expandInterpolatorId =
         attributes.GetResourceId(Resource.Styleable.expandable_selector_expand_interpolator,
             global::Android.Resource.Animation.AccelerateInterpolator);
     int collapseInterpolatorId =
         attributes.GetResourceId(Resource.Styleable.expandable_selector_collapse_interpolator,
             global::Android.Resource.Animation.DecelerateInterpolator);
     int containerInterpolatorId =
         attributes.GetResourceId(Resource.Styleable.expandable_selector_container_interpolator,
             global::Android.Resource.Animation.DecelerateInterpolator);
     this._expandableSelectorAnimator = new ExpandableSelectorAnimator(this, animationDuration,
         expandInterpolatorId,
         collapseInterpolatorId, containerInterpolatorId);
 }