protected internal override bool inflateTag(string name, android.content.res.Resources r, org.xmlpull.v1.XmlPullParser parser, android.util.AttributeSet attrs) { if (name.Equals("corners")) { android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected]. styleable.DrawableCorners); int radius = a.getDimensionPixelSize([email protected]_radius , 0); setCornerRadius(radius); // now check of they have any per-corner radii int topLeftRadius = a.getDimensionPixelSize([email protected]_topLeftRadius , radius); int topRightRadius = a.getDimensionPixelSize([email protected]_topRightRadius , radius); int bottomLeftRadius = a.getDimensionPixelSize([email protected]_bottomLeftRadius , radius); int bottomRightRadius = a.getDimensionPixelSize([email protected]_bottomRightRadius , radius); if (topLeftRadius != radius || topRightRadius != radius || bottomLeftRadius != radius || bottomRightRadius != radius) { setCornerRadii(new float[] { topLeftRadius, topLeftRadius, topRightRadius, topRightRadius , bottomLeftRadius, bottomLeftRadius, bottomRightRadius, bottomRightRadius }); } a.recycle(); return(true); } return(base.inflateTag(name, r, parser, attrs)); }
protected internal override void onMeasure(int widthMeasureSpec, int heightMeasureSpec ) { base.onMeasure(widthMeasureSpec, heightMeasureSpec); android.text.Layout layout_1 = getLayout(); if (layout_1 != null) { int lineCount = layout_1.getLineCount(); if (lineCount > 0) { int ellipsisCount = layout_1.getEllipsisCount(lineCount - 1); if (ellipsisCount > 0) { setSingleLine(false); setMaxLines(2); android.content.res.TypedArray a = mContext.obtainStyledAttributes(null, android.R .styleable.TextAppearance, android.R.attr.textAppearanceMedium, android.R.style. TextAppearance_Medium); int textSize = a.getDimensionPixelSize(android.R.styleable.TextAppearance_textSize , 0); if (textSize != 0) { // textSize is already expressed in pixels setTextSize(android.util.TypedValue.COMPLEX_UNIT_PX, textSize); } a.recycle(); base.onMeasure(widthMeasureSpec, heightMeasureSpec); } } } }
public ImageView(android.content.Context context, android.util.AttributeSet attrs , int defStyle) : base(context, attrs, defStyle) { initImageView(); android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected] .styleable.ImageView, defStyle, 0); android.graphics.drawable.Drawable d = a.getDrawable([email protected] .ImageView_src); if (d != null) { setImageDrawable(d); } mBaselineAlignBottom = a.getBoolean([email protected]_baselineAlignBottom , false); mBaseline = a.getDimensionPixelSize([email protected]_baseline , -1); setAdjustViewBounds(a.getBoolean([email protected]_adjustViewBounds , false)); setMaxWidth(a.getDimensionPixelSize([email protected]_maxWidth , int.MaxValue)); setMaxHeight(a.getDimensionPixelSize([email protected]_maxHeight , int.MaxValue)); int index = a.getInt([email protected]_scaleType, -1); if (index >= 0) { setScaleType(sScaleTypeArray[index]); } int tint = a.getInt([email protected]_tint, 0); if (tint != 0) { setColorFilter(tint); } int alpha = a.getInt([email protected]_drawableAlpha, 255); if (alpha != 255) { setAlpha(alpha); } mCropToPadding = a.getBoolean([email protected]_cropToPadding , false); a.recycle(); }
/// <summary>Instantiates the IconMenuView that is linked with the provided MenuBuilder. /// </summary> /// <remarks>Instantiates the IconMenuView that is linked with the provided MenuBuilder. /// </remarks> public IconMenuView(android.content.Context context, android.util.AttributeSet attrs ) : base(context, attrs) { android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected] .styleable.IconMenuView, 0, 0); mRowHeight = a.getDimensionPixelSize([email protected]_rowHeight , 64); mMaxRows = a.getInt([email protected]_maxRows, 2); mMaxItems = a.getInt([email protected]_maxItems, 6); mMaxItemsPerRow = a.getInt([email protected]_maxItemsPerRow , 3); mMoreIcon = a.getDrawable([email protected]_moreIcon); a.recycle(); a = context.obtainStyledAttributes(attrs, [email protected], 0, 0); mItemBackground = a.getDrawable([email protected]_itemBackground ); mHorizontalDivider = a.getDrawable([email protected]_horizontalDivider ); mHorizontalDividerRects = new java.util.ArrayList <android.graphics.Rect>(); mVerticalDivider = a.getDrawable([email protected]_verticalDivider ); mVerticalDividerRects = new java.util.ArrayList <android.graphics.Rect>(); mAnimations = a.getResourceId([email protected]_windowAnimationStyle , 0); a.recycle(); if (mHorizontalDivider != null) { mHorizontalDividerHeight = mHorizontalDivider.getIntrinsicHeight(); // Make sure to have some height for the divider if (mHorizontalDividerHeight == -1) { mHorizontalDividerHeight = 1; } } if (mVerticalDivider != null) { mVerticalDividerWidth = mVerticalDivider.getIntrinsicWidth(); // Make sure to have some width for the divider if (mVerticalDividerWidth == -1) { mVerticalDividerWidth = 1; } } mLayout = new int[mMaxRows]; // This view will be drawing the dividers setWillNotDraw(false); // This is so we'll receive the MENU key in touch mode setFocusableInTouchMode(true); // This is so our children can still be arrow-key focused setDescendantFocusability(FOCUS_AFTER_DESCENDANTS); }
/// <summary> /// Construct a new Switch with a default style determined by the given theme attribute, /// overriding specific style attributes as requested. /// </summary> /// <remarks> /// Construct a new Switch with a default style determined by the given theme attribute, /// overriding specific style attributes as requested. /// </remarks> /// <param name="context">The Context that will determine this widget's theming.</param> /// <param name="attrs">Specification of attributes that should deviate from the default styling. /// </param> /// <param name="defStyle"> /// An attribute ID within the active theme containing a reference to the /// default style for this widget. e.g. android.R.attr.switchStyle. /// </param> public Switch(android.content.Context context, android.util.AttributeSet attrs, int defStyle) : base(context, attrs, defStyle) { // Enum for the "typeface" XML parameter. // Does not include padding mTextPaint = new android.text.TextPaint(android.graphics.Paint.ANTI_ALIAS_FLAG); android.content.res.Resources res = getResources(); mTextPaint.density = res.getDisplayMetrics().density; mTextPaint.setCompatibilityScaling(res.getCompatibilityInfo().applicationScale); android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected] .styleable.Switch, defStyle, 0); mThumbDrawable = a.getDrawable([email protected]_thumb); mTrackDrawable = a.getDrawable([email protected]_track); mTextOn = a.getText([email protected]_textOn); mTextOff = a.getText([email protected]_textOff); mThumbTextPadding = a.getDimensionPixelSize([email protected]_thumbTextPadding , 0); mSwitchMinWidth = a.getDimensionPixelSize([email protected]_switchMinWidth , 0); mSwitchPadding = a.getDimensionPixelSize([email protected]_switchPadding , 0); int appearance = a.getResourceId([email protected]_switchTextAppearance , 0); if (appearance != 0) { setSwitchTextAppearance(context, appearance); } a.recycle(); android.view.ViewConfiguration config = android.view.ViewConfiguration.get(context ); mTouchSlop = config.getScaledTouchSlop(); mMinFlingVelocity = config.getScaledMinimumFlingVelocity(); // Refresh display with current params refreshDrawableState(); setChecked(isChecked()); }
/// <summary> /// Sets the switch text color, size, style, hint color, and highlight color /// from the specified TextAppearance resource. /// </summary> /// <remarks> /// Sets the switch text color, size, style, hint color, and highlight color /// from the specified TextAppearance resource. /// </remarks> public virtual void setSwitchTextAppearance(android.content.Context context, int resid) { android.content.res.TypedArray appearance = context.obtainStyledAttributes(resid, [email protected]); android.content.res.ColorStateList colors; int ts; colors = appearance.getColorStateList([email protected]_textColor ); if (colors != null) { mTextColors = colors; } else { // If no color set in TextAppearance, default to the view's textColor mTextColors = getTextColors(); } ts = appearance.getDimensionPixelSize([email protected]_textSize , 0); if (ts != 0) { if (ts != mTextPaint.getTextSize()) { mTextPaint.setTextSize(ts); requestLayout(); } } int typefaceIndex; int styleIndex; typefaceIndex = appearance.getInt([email protected]_typeface , -1); styleIndex = appearance.getInt([email protected]_textStyle , -1); setSwitchTypefaceByIndex(typefaceIndex, styleIndex); appearance.recycle(); }