private void init(IAttributeSet attrs) { TypedArray a = Context.ObtainStyledAttributes(attrs, Resource.Styleable.ColorPickerPreference); showDialogTitle = a.GetBoolean(Resource.Styleable.ColorPickerPreference_showDialogTitle, false); showPreviewSelectedColorInList = a.GetBoolean(Resource.Styleable.ColorPickerPreference_showSelectedColorInList, true); a.Recycle(); a = Context.ObtainStyledAttributes(attrs, Resource.Styleable.ColorPickerView); alphaChannelVisible = a.GetBoolean(Resource.Styleable.ColorPickerView_alphaChannelVisible, false); alphaChannelText = a.GetString(Resource.Styleable.ColorPickerView_alphaChannelText); colorPickerSliderColor = a.GetColor(Resource.Styleable.ColorPickerView_colorPickerSliderColor, -1); colorPickerBorderColor = a.GetColor(Resource.Styleable.ColorPickerView_colorPickerBorderColor, -1); a.Recycle(); if (showPreviewSelectedColorInList) { WidgetLayoutResource = Resource.Layout.preference_preview_layout; } if (!showDialogTitle) { DialogTitle = null; } DialogLayoutResource = Resource.Layout.dialog_color_picker; SetPositiveButtonText(Resource.String.dialog_ok); SetNegativeButtonText(Resource.String.dialog_cancle); Persistent = true; }
/// <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); }
//applies font from XML public static void ApplyCustomFont(TextView view, Context context, IAttributeSet attrs) { TypedArray attributeArray = context.ObtainStyledAttributes(attrs, Resource.Styleable.CustomFont); string fontName = attributeArray.GetString(Resource.Styleable.CustomFont_font); int textStyle = attrs.GetAttributeIntValue(ANDROID_SCHEMA, "textStyle", 0); Typeface customFont = SelectTypeface(context, fontName); switch (textStyle) { case 1: view.SetTypeface(customFont, TypefaceStyle.Bold); break; case 2: view.SetTypeface(customFont, TypefaceStyle.Italic); break; case 3: view.SetTypeface(customFont, TypefaceStyle.BoldItalic); break; default: view.SetTypeface(customFont, TypefaceStyle.Normal); break; } attributeArray.Recycle(); }
public LibraryGridView(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle) { TypedArray localTypedArray = context.ObtainStyledAttributes(attrs, Resource.Styleable.LibraryGridView, defStyle, 0); GridViewParams(localTypedArray); localTypedArray.Recycle(); }
private void initButton(Context context, IAttributeSet attrs) { if (context is Activity) { init((Activity)context); } TypedArray a = context.ObtainStyledAttributes(attrs, Resource.Styleable.ShineButton); btnColor = a.GetColor(Resource.Styleable.ShineButton_btn_color, Color.Gray); btnFillColor = a.GetColor(Resource.Styleable.ShineButton_btn_fill_color, Color.Black); shineParams.allowRandomColor = a.GetBoolean(Resource.Styleable.ShineButton_allow_random_color, false); shineParams.animDuration = a.GetInteger(Resource.Styleable.ShineButton_shine_animation_duration, (int)shineParams.animDuration); shineParams.bigShineColor = a.GetColor(Resource.Styleable.ShineButton_big_shine_color, shineParams.bigShineColor); shineParams.clickAnimDuration = a.GetInteger(Resource.Styleable.ShineButton_click_animation_duration, (int)shineParams.clickAnimDuration); shineParams.enableFlashing = a.GetBoolean(Resource.Styleable.ShineButton_enable_flashing, false); shineParams.shineCount = a.GetInteger(Resource.Styleable.ShineButton_shine_count, shineParams.shineCount); shineParams.shineDistanceMultiple = a.GetFloat(Resource.Styleable.ShineButton_shine_distance_multiple, shineParams.shineDistanceMultiple); shineParams.shineTurnAngle = a.GetFloat(Resource.Styleable.ShineButton_shine_turn_angle, shineParams.shineTurnAngle); shineParams.smallShineColor = a.GetColor(Resource.Styleable.ShineButton_small_shine_color, shineParams.smallShineColor); shineParams.smallShineOffsetAngle = a.GetFloat(Resource.Styleable.ShineButton_small_shine_offset_angle, shineParams.smallShineOffsetAngle); shineParams.shineSize = a.GetDimensionPixelSize(Resource.Styleable.ShineButton_shine_size, shineParams.shineSize); a.Recycle(); setSrcColor(btnColor); }
/** * 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 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(); }
public static bool IsHidesFooterIfEmptyEnabled(Context context, IAttributeSet attrs) { TryInitializeBindingResourcePaths(); TypedArray typedArray = null; bool hidesFooterIfEmpty = true; try { typedArray = context.ObtainStyledAttributes(attrs, MvxRecyclerViewGroupId); int numberOfStyles = typedArray.IndexCount; for (int i = 0; i < numberOfStyles; ++i) { var attributeId = typedArray.GetIndex(i); if (attributeId == MvxRecyclerViewHidesFooterIfEmpty) { hidesFooterIfEmpty = typedArray.GetBoolean(attributeId, true); break; } } return(hidesFooterIfEmpty); } finally { typedArray.Recycle(); } }
/** * Constructor that is called when inflating SwipeRefreshLayout from XML. * * @param context * @param attrs */ public SwipeRefreshLayout(Context context, IAttributeSet attrs) : base(context, attrs) { mRefreshListener = new CustomRefreshListener(this); mAnimateToCorrectPosition = new CustommAnimateToCorrectPosition(this); mAnimateToStartPosition = new CustommAnimateToStartPosition(this); mTouchSlop = ViewConfiguration.Get(context).ScaledTouchSlop; mMediumAnimationDuration = Resources.GetInteger( AndroidResource.Integer.ConfigMediumAnimTime); SetWillNotDraw(false); mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR); TypedArray a = context.ObtainStyledAttributes(attrs, LAYOUT_ATTRS); Enabled = (a.GetBoolean(0, true)); a.Recycle(); DisplayMetrics metrics = Resources.DisplayMetrics; mCircleWidth = (int)(CIRCLE_DIAMETER * metrics.Density); mCircleHeight = (int)(CIRCLE_DIAMETER * metrics.Density); createProgressView(); ViewCompat.SetChildrenDrawingOrderEnabled(this, true); // the absolute offset has to take into account that the circle starts at an offset mSpinnerFinalOffset = DEFAULT_CIRCLE_TARGET * metrics.Density; mTotalDragDistance = mSpinnerFinalOffset; RequestDisallowInterceptTouchEvent(true); }
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); }
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(); }
public SlidingTabLayoutPlus(Context context, IAttributeSet attrs) : base(context, attrs, 0) { this.mContext = context; SetFitsSystemWindows(true); SetWillNotDraw(false);//重写onDraw方法,需要调用这个方法来清除flag SetClipChildren(false); SetClipToPadding(false); this.mContext = context; mTabsContainer = new LinearLayout(context); AddView(mTabsContainer); obtainAttributes(context, attrs); var height = attrs.GetAttributeValue("http://schemas.android.com/apk/res/android", "layout_height");// model.GetValue("layout_height");// .GetAttributeValue("http://schemas.android.com/apk/res/android", "layout_height"); if (height.Equals(ViewGroup.LayoutParams.MatchParent + "")) { } else if (height.Equals(ViewGroup.LayoutParams.WrapContent + "")) { } else { int[] systemAttrs = { Android.Resource.Attribute.LayoutHeight }; TypedArray a = context.ObtainStyledAttributes(attrs, systemAttrs); mHeight = a.GetDimensionPixelSize(0, ViewGroup.LayoutParams.WrapContent); a.Recycle(); } }
public SupportGridItemDecoration(Context context) { TypedArray a = context.ObtainStyledAttributes(ATTRS); mDivider = a.GetDrawable(0); a.Recycle(); }
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); }
/** * Default divider will be used */ public DividerItemDecoration(Context context) { TypedArray styledAttributes = context.ObtainStyledAttributes(ATTRS); mDivider = styledAttributes.GetDrawable(0); styledAttributes.Recycle(); }
private void InitAttributes(Context context, IAttributeSet attrs) { if (attrs != null) { TypedArray array = context.ObtainStyledAttributes(attrs, Resource.Styleable.XCarousel); ItemsVisible = array.GetInteger(Resource.Styleable.XCarousel_itemsVisible, ItemsVisible); switch (ItemsVisible) { case 3: var threeValue = new TypedValue(); Resources.GetValue(Resource.Dimension.Three_Items, threeValue, true); Divisor = threeValue.Float; break; case 5: var fiveValue = new TypedValue(); Resources.GetValue(Resource.Dimension.Five_Items, fiveValue, true); Divisor = fiveValue.Float; break; case 7: var sevenValue = new TypedValue(); Resources.GetValue(Resource.Dimension.Seven_Items, sevenValue, true); break; default: Divisor = 3; break; } array.Recycle(); } }
private void Initialize(IAttributeSet attrs) { //Load those if set in xml resource file. TypedArray a = Context.ObtainStyledAttributes(attrs, Resource.Styleable.ColorPickerView); mShowAlphaPanel = a.GetBoolean(Resource.Styleable.ColorPickerView_alphaChannelVisible, false); mAlphaSliderText = a.GetString(Resource.Styleable.ColorPickerView_alphaChannelText); //TODO : cross check calculation mSliderTrackerColor = a.GetColor(Resource.Styleable.ColorPickerView_colorPickerSliderColor, Int32.Parse("FFBDBDBD", System.Globalization.NumberStyles.HexNumber)); mBorderColor = a.GetColor(Resource.Styleable.ColorPickerView_colorPickerBorderColor, Int32.Parse("FF6E6E6E", System.Globalization.NumberStyles.HexNumber)); a.Recycle(); mDensity = Context.Resources.DisplayMetrics.Density; PALETTE_CIRCLE_TRACKER_RADIUS *= mDensity; RECTANGLE_TRACKER_OFFSET *= mDensity; HUE_PANEL_WIDTH *= mDensity; ALPHA_PANEL_HEIGHT *= mDensity; PANEL_SPACING = PANEL_SPACING * mDensity; mDrawingOffset = calculateRequiredOffset(); initPaintTools(); //Needed for receiving trackball motion events. Focusable = true; FocusableInTouchMode = true; }
void Init(IAttributeSet attrs, int defStyleAttr, int defStyleRes) { TypedArray attrValues = Context.ObtainStyledAttributes(attrs, Resource.Styleable.BlurView, defStyleAttr, defStyleRes); _overlayColor = attrValues.GetColor(Resource.Styleable.BlurView_overlayColor, Color.Transparent); attrValues.Recycle(); }
private static string ReadRecyclerViewItemTemplateSelectorClassName(Context context, IAttributeSet attrs) { TryInitializeBindingResourcePaths(); TypedArray typedArray = null; string className = string.Empty; try { typedArray = context.ObtainStyledAttributes(attrs, MvxRecyclerViewItemTemplateSelectorGroupId); int numberOfStyles = typedArray.IndexCount; for (int i = 0; i < numberOfStyles; ++i) { var attributeId = typedArray.GetIndex(i); if (attributeId == MvxRecyclerViewItemTemplateSelector) { className = typedArray.GetString(attributeId); } } } finally { typedArray?.Recycle(); } if (string.IsNullOrEmpty(className)) { return(typeof(MvxDefaultTemplateSelector).FullName); } return(className); }
private void InitTextView(Context context, IAttributeSet attrs) { TypedArray a = context.Theme.ObtainStyledAttributes(attrs, Resource.Styleable.FuturaTextView, 0, 0); try { var textStyle = a.GetInteger(Resource.Styleable.FuturaTextView_textStyle, 0); if (textStyle == 0) { var assetManager = context.ApplicationContext.Assets; var typeFace = Android.Graphics.Typeface.CreateFromAsset(assetManager, "fonts/FuturaPT-Book.ttf"); SetTypeface(typeFace, Android.Graphics.TypefaceStyle.Normal); } else if (textStyle == 1) { var assetManager = context.ApplicationContext.Assets; var typeFace = Android.Graphics.Typeface.CreateFromAsset(assetManager, "fonts/FuturaPT-Medium.ttf"); SetTypeface(typeFace, Android.Graphics.TypefaceStyle.Normal); } } catch (Exception exp) { Console.Write(exp); } finally { a.Recycle(); } }
private void init(Context context, IAttributeSet attrs, int defStyleAttr, int defStyleRes) { mMinWidth = 24; mMaxWidth = 48; mMinHeight = 24; mMaxHeight = 48; TypedArray a = context.ObtainStyledAttributes( attrs, Resource.Styleable.AVLoadingIndicatorView, defStyleAttr, defStyleRes); mMinWidth = a.GetDimensionPixelSize(Resource.Styleable.AVLoadingIndicatorView_minWidth, mMinWidth); mMaxWidth = a.GetDimensionPixelSize(Resource.Styleable.AVLoadingIndicatorView_maxWidth, mMaxWidth); mMinHeight = a.GetDimensionPixelSize(Resource.Styleable.AVLoadingIndicatorView_minHeight, mMinHeight); mMaxHeight = a.GetDimensionPixelSize(Resource.Styleable.AVLoadingIndicatorView_maxHeight, mMaxHeight); string indicatorName = a.GetString(Resource.Styleable.AVLoadingIndicatorView_indicatorName); mIndicatorColor = a.GetColor(Resource.Styleable.AVLoadingIndicatorView_indicatorColor, Color.White); setIndicator(indicatorName); if (mIndicator == null) { setIndicator(DEFAULT_INDICATOR); } a.Recycle(); }
internal static List <string> ReadStringAttributeValue(Context context, IAttributeSet attrs, int[] groupId, ICollection <int> requiredAttributeIds) { TypedArray typedArray = context.Theme.ObtainStyledAttributes(attrs, groupId, 0, 0); try { List <string> result = null; foreach (int attributeId in requiredAttributeIds) { string s = typedArray.GetString(attributeId); if (string.IsNullOrEmpty(s)) { continue; } if (result == null) { result = new List <string>(); } result.Add(s); } return(result); } finally { typedArray.Recycle(); } }
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; }
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(); }
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(); } } }
public void InitButton(Context context, IAttributeSet attrs) { Activity activityCaller = context as Activity; if (activityCaller != null) { Init((Activity)context); } TypedArray a = context.ObtainStyledAttributes(attrs, Resource.Styleable.ShineButton); btnColor = a.GetColor(Resource.Styleable.ShineButton_btn_color, Color.Gray); ButtonFillColour = a.GetColor(Resource.Styleable.ShineButton_btn_fill_color, Color.Black); shineParams.UseRandomColor = a.GetBoolean(Resource.Styleable.ShineButton_allow_random_color, false); shineParams.AnimDuration = a.GetInteger(Resource.Styleable.ShineButton_shine_animation_duration, (int)shineParams.AnimDuration); shineParams.BigShineColor = a.GetColor(Resource.Styleable.ShineButton_big_shine_color, shineParams.BigShineColor); shineParams.ClickAnimDuration = a.GetInteger(Resource.Styleable.ShineButton_click_animation_duration, (int)shineParams.ClickAnimDuration); shineParams.EnableFlashing = a.GetBoolean(Resource.Styleable.ShineButton_enable_flashing, false); shineParams.ShineCount = a.GetInteger(Resource.Styleable.ShineButton_shine_count, shineParams.ShineCount); shineParams.ShineDistanceMultiple = a.GetFloat(Resource.Styleable.ShineButton_shine_distance_multiple, shineParams.ShineDistanceMultiple); shineParams.ShineTurnAngle = a.GetFloat(Resource.Styleable.ShineButton_shine_turn_angle, shineParams.ShineTurnAngle); shineParams.SmallShineColor = a.GetColor(Resource.Styleable.ShineButton_small_shine_color, shineParams.SmallShineColor); shineParams.SmallShineOffsetAngle = a.GetFloat(Resource.Styleable.ShineButton_small_shine_offset_angle, shineParams.SmallShineOffsetAngle); shineParams.ShineSize = a.GetDimensionPixelSize(Resource.Styleable.ShineButton_shine_size, shineParams.ShineSize); a.Recycle(); SourceColour = btnColor; }
private void LoadAttribute(Context context, IAttributeSet attrs) { TypedArray typedArray = context.Theme.ObtainStyledAttributes(attrs, Resource.Styleable.MusicBar, 0, 0); try { MLoadedBarSecondaryPaint.Color = typedArray.GetColor( Resource.Styleable.MusicBar_LoadedBarSecondaryColor, ContextCompat.GetColor(context, Resource.Color.LoadedBarSecondaryColor)); MBackgroundBarSecondaryPaint.Color = typedArray.GetColor( Resource.Styleable.MusicBar_backgroundBarSecondaryColor, ContextCompat.GetColor(context, Resource.Color.BackgroundBarSecondaryColor)); IsDivided = typedArray.GetBoolean(Resource.Styleable.MusicBar_divided, false); MDividerSize = typedArray.GetFloat(Resource.Styleable.MusicBar_dividerSize, 2); MBarWidth = typedArray.GetFloat(Resource.Styleable.MusicBar_barWidth, 3); MLoadedBarPrimeColor.StrokeWidth = MBarWidth; MBackgroundBarPrimeColor.StrokeWidth = MBarWidth; MLoadedBarSecondaryPaint.StrokeWidth = MBarWidth; MBackgroundBarSecondaryPaint.StrokeWidth = MBarWidth; MDividerSize = MBarWidth + MDividerSize; } catch (Exception e) { Console.WriteLine(e); } finally { typedArray.Recycle(); } }
private static string ReadItemTemplateSelectorClassName(Context context, IAttributeSet attrs) { TypedArray typedArray = null; string className = string.Empty; try { typedArray = context.ObtainStyledAttributes(attrs, GroupId); int numberOfStyles = typedArray.IndexCount; for (int i = 0; i < numberOfStyles; ++i) { var attributeId = typedArray.GetIndex(i); if (attributeId == ItemTemplateSelector) { className = typedArray.GetString(attributeId); } } } finally { typedArray?.Recycle(); } return(className); }
private void Init(Android.Content.Context context, IAttributeSet attrs) { TypedArray typedArray = context.ObtainStyledAttributes(attrs, Resource.Styleable.LoadingView); loadText = typedArray.GetString(Resource.Styleable.LoadingView_loadingText); typedArray.Recycle(); }
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(); }