Beispiel #1
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));
            }
        }
Beispiel #2
0
        public FillWidthImageButton(Context context, IAttributeSet attrs) : base(context, attrs)
        {
            SetOnTouchListener(this);

            _standardDrawableAvailable = new ManualResetEvent(false);

            TypedArray typeArray = context.ObtainStyledAttributes(attrs, Resource.Styleable.FillWidthImageButton);

            StandardDrawable = typeArray.GetDrawable(Resource.Styleable.FillWidthImageButton_standard_drawable) as BitmapDrawable;
            ClickedDrawable  = typeArray.GetDrawable(Resource.Styleable.FillWidthImageButton_clicked_drawable) as BitmapDrawable;
            typeArray.Recycle();
        }
Beispiel #3
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_marker_size, 25);
            mLineSize   = typedArray.GetDimensionPixelSize(Resource.Styleable.timeline_style_line_size, 2);
            typedArray.Recycle();
            if (mMarker == null)
            {
                mMarker = mContext.Resources.GetDrawable(Resource.Drawable.marker);
            }
        }
        public SimpleDivider(Context context)
        {
            TypedArray ta = context.ObtainStyledAttributes(attributes);

            divider = ta.GetDrawable(0);
            ta.Recycle();
        }
Beispiel #5
0
        public ChipView(Context context, IAttributeSet attrs, int defStyleAttr) : base(context, attrs, defStyleAttr)
        {
            TypedArray a = context.Theme.ObtainStyledAttributes(attrs, Resource.Styleable.ChipView, defStyleAttr, 0);

            if (a.HasValue(Resource.Styleable.ChipView_chip_text))
            {
                _chipText = a.GetString(Resource.Styleable.ChipView_chip_text);
            }
            _hasIcon = a.GetBoolean(Resource.Styleable.ChipView_enable_icon, false);
            if (a.HasValue(Resource.Styleable.ChipView_chip_icon))
            {
                _chipIcon = a.GetDrawable(Resource.Styleable.ChipView_chip_icon);
            }
            _closable                = a.GetBoolean(Resource.Styleable.ChipView_closeable, false);
            _selectable              = a.GetBoolean(Resource.Styleable.ChipView_chip_selectable, false);
            _backgroundColor         = a.GetColor(Resource.Styleable.ChipView_chip_backgroundColor, ContextCompat.GetColor(context, Resource.Color.default_chip_background_color));
            _selectedBackgroundColor = a.GetColor(Resource.Styleable.ChipView_chip_selectedBackgroundColor, ContextCompat.GetColor(context, Resource.Color.default_chip_background_clicked_color));
            _textColor               = a.GetColor(Resource.Styleable.ChipView_chip_text_color, ContextCompat.GetColor(context, Resource.Color.default_chip_text_color));
            _selectedTextColor       = a.GetColor(Resource.Styleable.ChipView_chip_selected_text_color, ContextCompat.GetColor(context, Resource.Color.default_chip_text_clicked_color));
            _closeColor              = a.GetColor(Resource.Styleable.ChipView_chip_close_color, ContextCompat.GetColor(context, Resource.Color.default_chip_close_inactive_color));
            _selectedCloseColor      = a.GetColor(Resource.Styleable.ChipView_chip_selected_close_color, ContextCompat.GetColor(context, Resource.Color.default_chip_close_clicked_color));
            _cornerRadius            = (int)a.GetDimension(Resource.Styleable.ChipView_chip_cornerRadius, Resources.GetDimension(Resource.Dimension.chip_height) / 2);
            _strokeSize              = (int)a.GetDimension(Resource.Styleable.ChipView_chip_strokeSize, 0);
            _strokeColor             = a.GetColor(Resource.Styleable.ChipView_chip_strokeColor, ContextCompat.GetColor(context, Resource.Color.default_chip_close_clicked_color));
            if (a.HasValue(Resource.Styleable.ChipView_chip_iconText))
            {
                _iconText = a.GetString(Resource.Styleable.ChipView_chip_iconText);
            }
            _iconTextColor           = a.GetColor(Resource.Styleable.ChipView_chip_iconTextColor, ContextCompat.GetColor(context, Resource.Color.default_chip_background_clicked_color));
            _iconTextBackgroundColor = a.GetColor(Resource.Styleable.ChipView_chip_iconTextBackgroundColor, ContextCompat.GetColor(context, Resource.Color.default_chip_close_clicked_color));
            a.Recycle();
            InitalizeViews(context);
        }
Beispiel #6
0
        /**
         * Default divider will be used
         */
        public DividerItemDecoration(Context context)
        {
            TypedArray styledAttributes = context.ObtainStyledAttributes(ATTRS);

            mDivider = styledAttributes.GetDrawable(0);
            styledAttributes.Recycle();
        }
Beispiel #7
0
        public DividerItemDecoration(Context context, IAttributeSet attrs)
        {
            TypedArray a = context.ObtainStyledAttributes(attrs, new int[] { Android.Resource.Attribute.ListDivider });

            mDivider = a.GetDrawable(0);
            a.Recycle();
        }
Beispiel #8
0
        public SupportGridItemDecoration(Context context)
        {
            TypedArray a = context.ObtainStyledAttributes(ATTRS);

            mDivider = a.GetDrawable(0);
            a.Recycle();
        }
        public DividerDecoration(Context context)
        {
            TypedArray a = context.ObtainStyledAttributes(Attrs);

            this.divider = a.GetDrawable(0);
            a.Recycle();
        }
Beispiel #10
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);
        }
Beispiel #11
0
        public RecyclerViewDecoration(Context context, int orientation)
        {
            TypedArray t = context.ObtainStyledAttributes(ATTRS);

            _divider = t.GetDrawable(0);
            t.Recycle();
            SetOrientation(orientation);
        }
Beispiel #12
0
 private void ApplyIcon(TypedArray attrs, int attributeIndex, ImageView targetView)
 {
     Drawable icon = attrs.GetDrawable(attributeIndex);
     if (icon != null)
     {
         targetView.SetImageDrawable(icon);
     }
 }
        public GeoListItemDecoration(Context context, int orientation)
        {
            TypedArray a = context.ObtainStyledAttributes(ATTRS);

            mDivider = a.GetDrawable(0);
            a.Recycle();
            setOrientation(orientation);
        }
        public DividerItemDecoration(Context context)
        {
            // Default divider
            TypedArray styledAttributes = context.ObtainStyledAttributes(new int[] { Android.Resource.Attribute.ListDivider });

            _divider       = styledAttributes.GetDrawable(0);
            _dividerHeight = _divider.IntrinsicHeight;
            //_dividerHeight = ThemeHelper.AsPx(context, 1);
        }
        private void InitAttributes(IAttributeSet attrs)
        {
            TypedArray styleable = Context.ObtainStyledAttributes(attrs, Resource.Styleable.FloatingTextButton, 0, 0);

            text       = styleable.GetString(Resource.Styleable.FloatingTextButton_floating_title);
            textColor  = styleable.GetColor(Resource.Styleable.FloatingTextButton_floating_title_color, Color.Black);
            leftIcon   = styleable.GetDrawable(Resource.Styleable.FloatingTextButton_floating_left_icon);
            background = styleable.GetColor(Resource.Styleable.FloatingTextButton_floating_background_color, Color.White);
            styleable.Recycle();
        }
Beispiel #16
0
            public MyDragShadowBuilder(View v)
                : base(v)
            {
                TypedArray a = v.Context.ObtainStyledAttributes(Resource.Styleable.AppTheme);

                mShadow          = a.GetDrawable(Resource.Styleable.AppTheme_listDragShadowBackground);
                mShadow.Callback = v;
                mShadow.SetBounds(0, 0, v.Width, v.Height);
                a.Recycle();
            }
Beispiel #17
0
 private void setup(Context context, IAttributeSet attrs, int defStyle)
 {
     if (attrs != null)
     {
         TypedArray typedArray = context.ObtainStyledAttributes(attrs, Resource.Styleable.PorterImageView, defStyle, 0);
         shape = typedArray.GetDrawable(Resource.Styleable.PorterImageView_siShape);
         typedArray.Recycle();
     }
     matrix = new Matrix();
 }
Beispiel #18
0
 public Drawable getOtherButtonMiddleBackground()
 {
     if (otherButtonMiddleBackground is StateListDrawable)
     {
         TypedArray a = mContext.Theme.ObtainStyledAttributes(null,
                                                              Resource.Styleable.ActionSheet, Resource.Attribute.actionSheetStyle, 0);
         otherButtonMiddleBackground = a
                                       .GetDrawable(Resource.Styleable.ActionSheet_otherButtonMiddleBackground);
         a.Recycle();
     }
     return(otherButtonMiddleBackground);
 }
Beispiel #19
0
        public static Drawable GetDrawable(this int attr, Context context)
        {
            int[] attrs = new int[] { attr };

            TypedArray ta = context.Theme.ObtainStyledAttributes(attrs);

            Drawable drawableFromTheme = ta.GetDrawable(0);

            ta.Recycle();

            return(drawableFromTheme);
        }
Beispiel #20
0
        public static Drawable ResolveDrawableAttr(Context context, int attrId)
        {
            TypedValue typedValue = ResolveThemeAttr(context, attrId);

            int[] attrs = new int[] { attrId };
            //int indexOfAttrTextSize = 0;
            TypedArray a     = context.ObtainStyledAttributes(typedValue.Data, attrs);
            var        value = a.GetDrawable(0);

            a.Recycle();

            return(value);
        }
        private void Init()
        {
            SetBackgroundColor(Color.White);
            SetPadding(0, 0, 0, 0);

            // Retrieve the drawable resource assigned to the Android.Resource.Attribute.SelectableItemBackground
            // theme attribute from the current theme.
            TypedArray a = Context.ObtainStyledAttributes(new[] { Android.Resource.Attribute.SelectableItemBackground });

            _foregroundDrawable = a.GetDrawable(0);
            _foregroundDrawable.SetCallback(this);
            a.Recycle();
        }
Beispiel #22
0
        Drawable GetActionBarBackgroundDrawable()
        {
            int[] backgroundDataArray = { global::Android.Resource.Attribute.Background };

            using (var outVal = new TypedValue())
            {
                _context.Theme.ResolveAttribute(global::Android.Resource.Attribute.ActionBarStyle, outVal, true);
                TypedArray actionBarStyle = _context.Theme.ObtainStyledAttributes(outVal.ResourceId, backgroundDataArray);

                Drawable result = actionBarStyle.GetDrawable(0);
                actionBarStyle.Recycle();
                return(result);
            }
        }
 public SupportDividerItemDecoration(Context context, int orientation, bool dash)
 {
     if (dash)
     {
         mDivider = ContextCompat.GetDrawable(context, Resource.Drawable.shape_common_dash_divide);
     }
     else
     {
         TypedArray a = context.ObtainStyledAttributes(ATTRS);
         mDivider = a.GetDrawable(0);
         a.Recycle();
     }
     setOrientation(orientation);
 }
Beispiel #24
0
        protected void Init(IAttributeSet attrs, int defStyleRes)
        {
            var @params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);

            _list = new DividerAwareLinearLayout(this.Context, null);
            _list.LayoutParameters = @params;
            _list.Orientation      = Orientation.Vertical;
            AddFocusable();
            AddView(_list);

            LinearDialogStyleableResource.Initialise();

            TypedArray a = Context.ObtainStyledAttributes(attrs, LinearDialogStyleableResource.LinearDialogScrollViewStylableGroupId, defStyleRes, 0);

            if (LinearDialogStyleableResource.LinearDialogScrollViewDivider > -1)
            {
                _list.DividerDrawable = a.GetDrawable(LinearDialogStyleableResource.LinearDialogScrollViewDivider);
            }
            if (LinearDialogStyleableResource.LinearDialogScrollViewShowDividers > -1)
            {
                _list.ShowDividers = a.GetInt(LinearDialogStyleableResource.LinearDialogScrollViewShowDividers, DividerAwareLinearLayout.SHOW_DIVIDER_NONE);
            }
            if (LinearDialogStyleableResource.LinearDialogScrollDividerPadding > -1)
            {
                _list.DividerPadding = a.GetDimensionPixelSize(LinearDialogStyleableResource.LinearDialogScrollDividerPadding, 0);
            }
            if (LinearDialogStyleableResource.LinearDialogScrollDividerHeight > -1)
            {
                _list.DividerHeight = a.GetDimensionPixelSize(LinearDialogStyleableResource.LinearDialogScrollDividerHeight, 0);
            }
            if (LinearDialogStyleableResource.LinearDialogScrollItemBackgroundDrawable > -1)
            {
                ItemBackgroundDrawable = a.GetDrawable(LinearDialogStyleableResource.LinearDialogScrollItemBackgroundDrawable);
            }

            a.Recycle();
        }
        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);
        }
        private static Drawable ResolveDrawable(Context context, int attr, Drawable fallback)
        {
            TypedArray a = context.Theme.ObtainStyledAttributes(new int[] { attr });

            try
            {
                Drawable d = a.GetDrawable(0);
                if (d == null && fallback != null)
                {
                    d = fallback;
                }
                return(d);
            }
            finally
            {
                a.Recycle();
            }
        }
Beispiel #27
0
        private void Init(IAttributeSet attrs, int defStyleAttr)
        {
            TypedArray t = Context.ObtainStyledAttributes(attrs, new int[] { Resource.Attribute.clearIconDrawable, Resource.Attribute.clearIconDrawWhenFocused }, defStyleAttr, 0);

            if (t.HasValue(0))
            {
                mClearIconDrawable = t.GetDrawable(0);

                if (mClearIconDrawable != null)
                {
                    mClearIconDrawable.Callback = this;
                }
            }

            mClearIconDrawWhenFocused = t.GetBoolean(1, true);

            t.Recycle();
        }
        public static Drawable GetAttributeDrawable(Context context, int attributeId)
        {
            // http://stackoverflow.com/questions/20531516/how-do-i-add-selectableitembackground-to-an-imagebutton-programatically

            int[] attrs = new int[] { attributeId };

            TypedArray ta = context.ObtainStyledAttributes(attrs);

            try
            {
                Drawable drawable = ta.GetDrawable(0);
                return(drawable);
            }

            finally
            {
                ta.Recycle();
            }
        }
        public LinePageIndicator(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle)
        {
            if (IsInEditMode)
            {
                return;
            }

            //Load defaults from resources
            int   defaultSelectedColor   = Resources.GetColor(Resource.Color.default_line_indicator_selected_color);
            int   defaultUnselectedColor = Resources.GetColor(Resource.Color.default_line_indicator_unselected_color);
            float defaultLineWidth       = Resources.GetDimension(Resource.Dimension.default_line_indicator_line_width);
            float defaultGapWidth        = Resources.GetDimension(Resource.Dimension.default_line_indicator_gap_width);
            float defaultStrokeWidth     = Resources.GetDimension(Resource.Dimension.default_line_indicator_stroke_width);
            bool  defaultCentered        = Resources.GetBoolean(Resource.Boolean.default_line_indicator_centered);

            //Retrieve styles attributes
            TypedArray a = context.ObtainStyledAttributes(attrs, Resource.Styleable.LinePageIndicator, defStyle, 0);

            centered  = a.GetBoolean(Resource.Styleable.LinePageIndicator_centered, defaultCentered);
            lineWidth = a.GetDimension(Resource.Styleable.LinePageIndicator_lineWidth, defaultLineWidth);
            gapWidth  = a.GetDimension(Resource.Styleable.LinePageIndicator_gapWidth, defaultGapWidth);
            SetStrokeWidth(a.GetDimension(Resource.Styleable.LinePageIndicator_strokeWidth, defaultStrokeWidth));
            paintUnselected.Color = a.GetColor(Resource.Styleable.LinePageIndicator_unselectedColor, defaultUnselectedColor);
            paintSelected.Color   = a.GetColor(Resource.Styleable.LinePageIndicator_selectedColor, defaultSelectedColor);

            Drawable background = a.GetDrawable(Resource.Styleable.LinePageIndicator_android_background);

            if (background != null)
            {
                SetBackgroundDrawable(background);
            }

            a.Recycle();

            ViewConfiguration configuration = ViewConfiguration.Get(context);

            mTouchSlop = ViewConfigurationCompat.GetScaledPagingTouchSlop(configuration);
        }
Beispiel #30
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            var row = _inflater.Inflate(Resource.Layout.DrawerListItemView, parent, false);
            var vh  = new DrawerListViewHolder(row);

            vh.Icon.SetImageDrawable(_drawerMenuImages.GetDrawable(position));
            vh.Text.Text = _drawerMenuList [position];
            row.Click   += (object sender, EventArgs e) => {
                Toast.MakeText(_Context, "23523", ToastLength.Short).Show();
            };
            vh.Badge.Visibility = ViewStates.Invisible;
            if (position == 0 && _badges.Messages > 0)
            {
                vh.Badge.Visibility = ViewStates.Visible;
                vh.Badge.Text       = "" + _badges.Messages;
            }
            if (position == 1 && _badges.Feed > 0)
            {
                vh.Badge.Visibility = ViewStates.Visible;
                vh.Badge.Text       = "" + _badges.Feed;
            }
            return(row);
        }
        public LoadingLayout(Context context, Mode mode, PtrOrientation scrollDirection, TypedArray attrs)
            : base(context)
        {
            //base(context);
            mMode = mode;
            mScrollDirection = scrollDirection;

            switch (scrollDirection)
            {
                case PtrOrientation.HORIZONTAL:
                    LayoutInflater.From(context).Inflate(Resource.Layout.pull_to_refresh_header_horizontal, this);
                    break;
                case PtrOrientation.VERTICAL:
                default:
                    LayoutInflater.From(context).Inflate(Resource.Layout.pull_to_refresh_header_vertical, this);
                    break;
            }

            mInnerLayout = (FrameLayout)FindViewById(Resource.Id.fl_inner);
            mHeaderText = (TextView)mInnerLayout.FindViewById(Resource.Id.pull_to_refresh_text);
            mHeaderProgress = (ProgressBar)mInnerLayout.FindViewById(Resource.Id.pull_to_refresh_progress);
            mSubHeaderText = (TextView)mInnerLayout.FindViewById(Resource.Id.pull_to_refresh_sub_text);
            mHeaderImage = (ImageView)mInnerLayout.FindViewById(Resource.Id.pull_to_refresh_image);

            FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams)mInnerLayout.LayoutParameters;

            switch (mode)
            {
                case Mode.PULL_FROM_END:
                    lp.Gravity = scrollDirection == PtrOrientation.VERTICAL ? GravityFlags.Top : GravityFlags.Left;

                    // Load in labels
                    mPullLabel = context.GetString(Resource.String.pull_to_refresh_from_bottom_pull_label);
                    mRefreshingLabel = context.GetString(Resource.String.pull_to_refresh_from_bottom_refreshing_label);
                    mReleaseLabel = context.GetString(Resource.String.pull_to_refresh_from_bottom_release_label);
                    break;

                case Mode.PULL_FROM_START:
                default:
                    lp.Gravity = scrollDirection == PtrOrientation.VERTICAL ? GravityFlags.Bottom : GravityFlags.Right;

                    // Load in labels
                    mPullLabel = context.GetString(Resource.String.pull_to_refresh_pull_label);
                    mRefreshingLabel = context.GetString(Resource.String.pull_to_refresh_refreshing_label);
                    mReleaseLabel = context.GetString(Resource.String.pull_to_refresh_release_label);
                    break;
            }



            if (attrs.HasValue(Resource.Styleable.PullToRefresh_ptrHeaderBackground))
            {
                Drawable background = attrs.GetDrawable(Resource.Styleable.PullToRefresh_ptrHeaderBackground);
                if (null != background)
                {
                    ViewCompat.setBackground(this, background);
                }
            }

            if (attrs.HasValue(Resource.Styleable.PullToRefresh_ptrHeaderTextAppearance))
            {
                TypedValue styleID = new TypedValue();
                attrs.GetValue(Resource.Styleable.PullToRefresh_ptrHeaderTextAppearance, styleID);
                setTextAppearance(styleID.Data);
            }
            if (attrs.HasValue(Resource.Styleable.PullToRefresh_ptrSubHeaderTextAppearance))
            {
                TypedValue styleID = new TypedValue();
                attrs.GetValue(Resource.Styleable.PullToRefresh_ptrSubHeaderTextAppearance, styleID);
                setSubTextAppearance(styleID.Data);
            }

            // Text Color attrs need to be set after TextAppearance attrs
            if (attrs.HasValue(Resource.Styleable.PullToRefresh_ptrHeaderTextColor))
            {
                ColorStateList colors = attrs.GetColorStateList(Resource.Styleable.PullToRefresh_ptrHeaderTextColor);
                if (null != colors)
                {
                    setTextColor(colors);
                }
            }
            if (attrs.HasValue(Resource.Styleable.PullToRefresh_ptrHeaderSubTextColor))
            {
                ColorStateList colors = attrs.GetColorStateList(Resource.Styleable.PullToRefresh_ptrHeaderSubTextColor);
                if (null != colors)
                {
                    setSubTextColor(colors);
                }
            }

            // Try and get defined drawable from Attrs
            Drawable imageDrawable = null;
            if (attrs.HasValue(Resource.Styleable.PullToRefresh_ptrDrawable))
            {
                imageDrawable = attrs.GetDrawable(Resource.Styleable.PullToRefresh_ptrDrawable);
            }

            // Check Specific Drawable from Attrs, these overrite the generic
            // drawable attr above
            switch (mode)
            {
                case Mode.PULL_FROM_START:
                default:

                    if (attrs.HasValue(Resource.Styleable.PullToRefresh_ptrDrawableStart))
                    {
                        imageDrawable = attrs.GetDrawable(Resource.Styleable.PullToRefresh_ptrDrawableStart);
                    }
                    else if (attrs.HasValue(Resource.Styleable.PullToRefresh_ptrDrawableTop))
                    {
                        Utils.warnDeprecation("ptrDrawableTop", "ptrDrawableStart");
                        imageDrawable = attrs.GetDrawable(Resource.Styleable.PullToRefresh_ptrDrawableTop);
                    }
                    break;

                case Mode.PULL_FROM_END:
                    if (attrs.HasValue(Resource.Styleable.PullToRefresh_ptrDrawableEnd))
                    {
                        imageDrawable = attrs.GetDrawable(Resource.Styleable.PullToRefresh_ptrDrawableEnd);
                    }
                    else if (attrs.HasValue(Resource.Styleable.PullToRefresh_ptrDrawableBottom))
                    {
                        Utils.warnDeprecation("ptrDrawableBottom", "ptrDrawableEnd");
                        imageDrawable = attrs.GetDrawable(Resource.Styleable.PullToRefresh_ptrDrawableBottom);
                    }
                    break;
            }

            // If we don't have a user defined drawable, load the default
            if (null == imageDrawable)
            {

                imageDrawable = context.Resources.GetDrawable(getDefaultDrawableResId());
            }

            // Set Drawable, and save width/height
            setLoadingDrawable(imageDrawable);

            reset();
        }