public MapViewLayoutParams(Context context, IAttributeSet attrs) : base(context, attrs) { this.X = attrs.GetAttributeIntValue("http://schemas.mapquest.com/apk/res/mapquest", "x", int.MaxValue); this.Y = attrs.GetAttributeIntValue("http://schemas.mapquest.com/apk/res/mapquest", "x", int.MaxValue); String geoPoint = attrs.GetAttributeValue("http://schemas.mapquest.com/apk/res/mapquest", "geoPoint"); if ((geoPoint.Length > 0)) { String[] arr = geoPoint.Split(new[] { "," }, StringSplitOptions.None); if (arr.Length > 1) { try { double latitude = Double.Parse(arr[0].Trim()); double longitude = Double.Parse(arr[1].Trim()); this.Point = new GeoPoint(latitude, longitude); this.Mode = 0; } catch (NumberFormatException nfe) { Log.Error("mq.android.maps.mapview", "Invalid value for geoPoint attribute : " + geoPoint); } } } }
public SeekBarPreference(Context context, IAttributeSet attrs) : base(context, attrs) { mContext = context; mDialogMessage = attrs.GetAttributeValue(androidns, "dialogMessage"); mSuffix = attrs.GetAttributeValue(androidns, "text"); mDefault = attrs.GetAttributeIntValue(androidns, "defaultValue", 0); mMax = attrs.GetAttributeIntValue(androidns, "max", 100); mValue = GetPersistedInt(mDefault); }
public BindableViewPager(Context context, IAttributeSet attrs, MvxBindablePagerAdapter adapter) : base(context, attrs) { this._initialIndex = attrs.GetAttributeIntValue("http://schemas.android.com/apk/res-auto", "selectedIndex", -1); this.OffscreenPageLimit = attrs.GetAttributeIntValue("http://schemas.android.com/apk/res-auto", "offscreenPageLimit", 1); var itemTemplateId = MvxAttributeHelpers.ReadListItemTemplateId(context, attrs); adapter.ItemTemplateId = itemTemplateId; Adapter = adapter; }
public SeekBarPreference(Context context, IAttributeSet attrs) : base(context, attrs) { _progress = 0; _minimumValue = attrs.GetAttributeIntValue(_applicationNamespace, "minValue", 0); _defaultValue = attrs.GetAttributeIntValue(_applicationNamespace, "defaultValue", 0) - _minimumValue; _maximumValue = attrs.GetAttributeIntValue(_applicationNamespace, "maxValue", 100) - _minimumValue; int suffixResourceId = attrs.GetAttributeResourceValue(_applicationNamespace, "suffix", 0); if (suffixResourceId > 0) _suffix = " " + context.Resources.GetString(suffixResourceId); DialogLayoutResource = Resource.Layout.TimeoutDialogPreference; }
//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 View OnCreateView(string name, Context context, IAttributeSet attrs) { var attributeValue = attrs.GetAttributeIntValue("http://schemas.android.com/apk/res-auto", "typeface", -1); if (attributeValue == -1) { return(null); } try { var view = CreateView(name, context, attrs); if (view == null) { return(null); } var font = this.ObtainTypeface(context, attributeValue); view.SetTypeface(font, m_Style); return(view); } catch (Exception) { } return(null); }
//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 SeekBarPreference(Context context, IAttributeSet attrs) : base(context, attrs) { _progress = 0; _minimumValue = attrs.GetAttributeIntValue(_applicationNamespace, "minValue", 0); _defaultValue = attrs.GetAttributeIntValue(_applicationNamespace, "defaultValue", 0) - _minimumValue; _maximumValue = attrs.GetAttributeIntValue(_applicationNamespace, "maxValue", 100) - _minimumValue; int suffixResourceId = attrs.GetAttributeResourceValue(_applicationNamespace, "suffix", 0); if (suffixResourceId > 0) { _suffix = " " + context.Resources.GetString(suffixResourceId); } DialogLayoutResource = Resource.Layout.TimeoutDialogPreference; }
private void SetValuesFromXml(IAttributeSet attrs) { maxValue = attrs.GetAttributeIntValue(ANDROIDNS, "max", 100); minValue = attrs.GetAttributeIntValue(APPLICATIONNS, "min", 0); unitsLeft = GetAttributeStringValue(attrs, APPLICATIONNS, "unitsLeft", ""); var units = GetAttributeStringValue(attrs, APPLICATIONNS, "units", ""); unitsRight = GetAttributeStringValue(attrs, APPLICATIONNS, "unitsRight", units); var newInterval = attrs.GetAttributeValue(APPLICATIONNS, "interval"); if (newInterval != null) { int.TryParse(newInterval, out interval); } }
private void InitializeFromAttributes(Context context, IAttributeSet attrs) { var attr = context.ObtainStyledAttributes(attrs, Resource.Styleable.DataTableView, 0, 0); LazyLoad = attr.GetBoolean(Resource.Styleable.DataTableView_lazyLoad, false); LazyLoadLimit = attr.GetInteger(Resource.Styleable.DataTableView_lazyLoadLimit, 0); ChoiceMode = (ChoiceMode)attrs.GetAttributeIntValue(Android.Resource.Attribute.ChoiceMode, 0); HeaderTextSize = attr.GetFloat(Resource.Styleable.DataTableView_headerTextSize, 20.0f); HeaderTextColor = attr.GetColor(Resource.Styleable.DataTableView_headerTextColor, unchecked ((int)0xFFFFFFFF)); var headerFontID = attr.GetResourceId(Resource.Styleable.DataTableView_headerFontFamily, -1); if (headerFontID >= 0) { HeaderTypeface = ResourcesCompat.GetFont(Context, headerFontID); } HeaderBackground = attr.GetDrawable(Resource.Styleable.DataTableView_headerBackground); RowTextSize = attr.GetFloat(Resource.Styleable.DataTableView_rowTextSize, DataTableAdapter.DEFAULT_TEXT_SIZE); RowTextColor = attr.GetColor(Resource.Styleable.DataTableView_rowTextColor, DataTableAdapter.DEFAULT_TEXT_COLOR); var rowFontID = attr.GetResourceId(Resource.Styleable.DataTableView_rowFontFamily, -1); if (rowFontID >= 0) { RowTypeface = ResourcesCompat.GetFont(Context, rowFontID); } RowBackground = attr.GetDrawable(Resource.Styleable.DataTableView_rowBackground); HorizontalRowDivider = attr.GetDrawable(Resource.Styleable.DataTableView_horizontalRowDivider) ?? ResourcesCompat.GetDrawable(Resources, Resource.Drawable.horizontal_divider, null); VerticalRowDivider = attr.GetDrawable(Resource.Styleable.DataTableView_verticalRowDivider) ?? ResourcesCompat.GetDrawable(Resources, Resource.Drawable.vertical_divider, null); CreateAdapter(); CreateHeaderView(); CreateRowView(); }
private void InitializeFromAttributes(Context context, IAttributeSet attrs) { var attr = context.ObtainStyledAttributes(attrs, Resource.Styleable.FileTextView, 0, 0); LazyLoad = attr.GetBoolean(Resource.Styleable.FileTextView_lazyLoad, false); LazyLoadLimit = attr.GetInteger(Resource.Styleable.FileTextView_lazyLoadLimit, 0); ChoiceMode = (ChoiceMode)attrs.GetAttributeIntValue(Android.Resource.Attribute.ChoiceMode, 0); RowTextSize = attr.GetFloat(Resource.Styleable.FileTextView_rowTextSize, TextRowAdapter.DEFAULT_TEXT_SIZE); RowTextColor = attr.GetColor(Resource.Styleable.FileTextView_rowTextColor, TextRowAdapter.DEFAULT_TEXT_COLOR); var rowFontID = attr.GetResourceId(Resource.Styleable.FileTextView_rowFontFamily, -1); /*if (rowFontID != -1) * { * RowTypeface = (true) ? ResourcesCompat.Get(Context, rowFontID) : Context.Resources.GetFont(rowFontID); * }*/ RowBackground = attr.GetDrawable(Resource.Styleable.FileTextView_rowBackground); LineNumberTextSize = attr.GetFloat(Resource.Styleable.FileTextView_lineNumberTextSize, TextRowAdapter.DEFAULT_NUMBER_SIZE); LineNumberColor = attr.GetColor(Resource.Styleable.FileTextView_lineNumberTextColor, TextRowAdapter.DEFAULT_NUMBER_COLOR); var lineNumberFontID = attr.GetResourceId(Resource.Styleable.FileTextView_lineNumberFontFamily, -1); /*if (lineNumberFontID != -1) * { * LineNumberTypeface = (true) ? ResourcesCompat.Get(Context, lineNumberFontID) : Context.Resources.GetFont(lineNumberFontID); * }*/ LineNumberBackground = attr.GetDrawable(Resource.Styleable.FileTextView_lineNumberBackground); HorizontalRowDivider = attr.GetDrawable(Resource.Styleable.FileTextView_horizontalRowDivider) ?? ResourcesCompat.GetDrawable(Resources, Resource.Drawable.horizontal_divider_semi, null); VerticalRowDivider = attr.GetDrawable(Resource.Styleable.FileTextView_verticalRowDivider) ?? ResourcesCompat.GetDrawable(Resources, Resource.Drawable.vertical_divider_semi, null); CreateRowView(); }
public View OnCreateView(string name, Context context, IAttributeSet attrs) { var attributeValue = attrs.GetAttributeIntValue("http://schemas.android.com/apk/res-auto", "typeface", -1); if (attributeValue == -1) return null; try { var view = CreateView(name, context, attrs); if (view == null) return null; var font = this.ObtainTypeface(context, attributeValue); view.SetTypeface(font, m_Style); return view; } catch (Exception) { } return null; }
public static void InitializeAttributes(this IElement element, IAttributeSet attrs) { if (element is View view && view.Id > 0) { element.ID = DroidFactory.MainActivity.Resources.GetResourceEntryName(view.Id); } if (attrs == null) { return; } const int adj = Element.AutoLayoutIndex + 1; var column = attrs.GetAttributeIntValue(XmlNamespace, "column", adj); if (column > adj) { element.ColumnIndex = column - 1; } var columnSpan = attrs.GetAttributeIntValue(XmlNamespace, "columnSpan", 1); if (columnSpan > 1) { element.ColumnSpan = columnSpan; } var row = attrs.GetAttributeIntValue(XmlNamespace, "row", adj); if (row > adj) { element.RowIndex = row - 1; } var rowSpan = attrs.GetAttributeIntValue(XmlNamespace, "rowSpan", 1); if (rowSpan > 1) { element.RowSpan = rowSpan; } var hAligns = Enum.GetNames(typeof(HorizontalAlignment)).Select(h => h.ToLower()).ToArray(); var horizontalAlignment = attrs.GetAttributeListValue(XmlNamespace, "horizontalAlignment", hAligns, 0); if (horizontalAlignment > 0) { element.HorizontalAlignment = (HorizontalAlignment)horizontalAlignment; } var vAligns = Enum.GetNames(typeof(VerticalAlignment)).Select(v => v.ToLower()).ToArray(); var verticalAlignment = attrs.GetAttributeListValue(XmlNamespace, "verticalAlignment", vAligns, 0); if (verticalAlignment > 0) { element.VerticalAlignment = (VerticalAlignment)verticalAlignment; } var visibles = Enum.GetNames(typeof(Visibility)).Select(v => v.ToLower()).ToArray(); var visibility = attrs.GetAttributeListValue(XmlNamespace, "visibility", visibles, 0); if (visibility > 0) { element.Visibility = (Visibility)visibility; } string font = attrs.GetAttributeValue(XmlNamespace, "font"); if (font != null) { var fontProp = Device.Reflector.GetProperty(typeof(Font), font); if (fontProp != null) { var value = fontProp.GetValue(Font.PreferredLabelFont); Device.Reflector.GetProperty(element.GetType(), "Font")?.SetValue(element, value); } else { var defaults = MXContainer.Resolve <IPlatformDefaults>(typeof(IPlatformDefaults)); var defaultsProp = Device.Reflector.GetProperty(defaults.GetType(), font); if (defaultsProp != null) { var value = defaultsProp.GetValue(defaults); Device.Reflector.GetProperty(element.GetType(), "Font")?.SetValue(element, value); } } } element.SetColor(attrs, "BackgroundColor"); element.SetColor(attrs, "ForegroundColor"); var margin = attrs.GetAttributeValue(XmlNamespace, "margin"); if (!string.IsNullOrEmpty(margin)) { var padValues = margin.Split(',').Select(p => p.TryParseDouble()).ToList(); switch (padValues.Count) { case 1: element.Margin = new Thickness(padValues[0]); break; case 2: element.Margin = new Thickness(padValues[0], padValues[1]); break; case 4: element.Margin = new Thickness(padValues[0], padValues[1], padValues[2], padValues[3]); break; default: throw new FormatException("Invalid margin format: " + margin); } } var left = ParseThickness(attrs, "marginLeft", (int)element.Margin.Left); var top = ParseThickness(attrs, "marginTop", (int)element.Margin.Top); var right = ParseThickness(attrs, "marginRight", (int)element.Margin.Right); var bottom = ParseThickness(attrs, "marginBottom", (int)element.Margin.Bottom); element.Margin = new Thickness(left, top, right, bottom); var submitKey = attrs.GetAttributeValue(XmlNamespace, "submitKey"); if (submitKey != null && element is IControl control) { control.SubmitKey = submitKey; } }
private void SetValuesFromXml(IAttributeSet attrs) { maxValue = attrs.GetAttributeIntValue (ANDROIDNS, "max", 100); minValue = attrs.GetAttributeIntValue (APPLICATIONNS, "min", 0); unitsLeft = GetAttributeStringValue (attrs, APPLICATIONNS, "unitsLeft", ""); var units = GetAttributeStringValue (attrs, APPLICATIONNS, "units", ""); unitsRight = GetAttributeStringValue (attrs, APPLICATIONNS, "unitsRight", units); var newInterval = attrs.GetAttributeValue (APPLICATIONNS, "interval"); if (newInterval != null) int.TryParse (newInterval, out interval); }