private void TestFont() { //Font TextView textViewFont = FindViewById <TextView>(Resource.Id.textViewFont); //Android.Graphics.Typeface typeface = this.Resources.GetFont(Resource.Font.SourceSansPro_bold); //GetFont方法已经不能使用 //textViewFont.Typeface = typeface; //textViewFont.Text = "Changed the font"; var typeface = Typeface.Create("<FONT FAMILY NAME>", Android.Graphics.TypefaceStyle.Bold); textViewFont.Typeface = typeface; Button btnTransferFont = FindViewById <Button>(Resource.Id.btnTransferFont); int times = 0; btnTransferFont.Click += (sender, e) => { times++; if (times % 2 == 0) { typeface = Typeface.Create("<FONT FAMILY NAME>", Android.Graphics.TypefaceStyle.Bold); } else { typeface = Typeface.Create("<FONT FAMILY NAME>", Android.Graphics.TypefaceStyle.Italic); } textViewFont.Typeface = typeface; }; }
void SetTitle() { if (GetToolbar() != null) { for (var i = 0; i < toolbar.ChildCount; i++) { var Title = toolbar.GetChildAt(i); if (Title is TextView title) { if (TitleHorizontalAlignment == HorizontalAlignmentEnum.Center) { float toolbarCenter = toolbar.Width / 2; float titleCenter = title.Width / 2; title.SetX(toolbarCenter - titleCenter); } if (!string.IsNullOrWhiteSpace(FontFamily)) { var typeface = Typeface.Create(FontFamily, ConvertFontAttributesToTypefaceStyle(TitleFontAttributes)); title.Typeface = typeface; } if (TitleFontSize != 0) { title.TextSize = TitleFontSize; } } } } }
private void SetFont() { using (var typeface = Typeface.Create(_FontFamily, IsItalic ? TypefaceStyle.Italic : TypefaceStyle.Normal)) { _native.SetTypeface(typeface); } }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Label> e) { base.OnElementChanged(e); if (e.OldElement == null) { //Only enable hardware accelleration on lollipop if ((int)Android.OS.Build.VERSION.SdkInt < 21) { SetLayerType(LayerType.Software, null); } } if (!string.IsNullOrEmpty(((IconAwesomeLabelBase)Element).Icon)) { Control.Typeface = Typeface.CreateFromAsset(context.Assets, TemplateSpartaneApp.Extensions.IconExtensions.FindNameFileForFont(((IconAwesomeLabelBase)Element).FontIcon)); IIcon icon = TemplateSpartaneApp.Extensions.IconExtensions.FindIconForKey(((IconAwesomeLabelBase)Element).Icon); Element.Text = $"{icon.Character}"; } else { Control.Typeface = Typeface.Create(Element.FontFamily, TypefaceStyle.Normal); Element.Text = ((IconAwesomeLabelBase)Element).Text; } }
public MapRowView(Context context) : base(context) { Id = RowId; Orientation = Orientation.Vertical; title = new TextView(context); title.SetTypeface(Typeface.Create("sans-serif-light", TypefaceStyle.Bold), TypefaceStyle.Bold); title.SetTextSize(Android.Util.ComplexUnitType.Dip, 16); title.SetTextColor(Color.Black); title.Gravity = Android.Views.GravityFlags.CenterVertical; description = new TextView(context); description.SetTypeface(Typeface.Create("sans-serif-thin", TypefaceStyle.Bold), TypefaceStyle.Bold); description.SetTextSize(Android.Util.ComplexUnitType.Dip, 13); description.SetTextColor(Color.DarkGray); topBorder = new RelativeLayout(context); AddView(topBorder); AddView(title); AddView(description); }
protected override void OnSizeChanged(int w, int h, int oldw, int oldh) { //temp = new Canvas(bitmap); //bitmap = Bitmap.CreateBitmap(w, h, Bitmap.Config.Argb8888); paint = new Paint(); paint.Color = Color.Argb(230, 0, 0, 0); transparentPaint = new Paint(); transparentPaint.Color = Color.Argb(0, 0, 0, 0); transparentPaint.SetXfermode(new PorterDuffXfermode(PorterDuff.Mode.Clear)); transparentPaint.AntiAlias = true; textPaint = new Paint(PaintFlags.AntiAlias); textPaint.Color = Color.White; textPaint.TextSize = Utils.sp2px(Context, 18); Typeface currentTypeFace = textPaint.Typeface; Typeface bold = Typeface.Create(currentTypeFace, TypefaceStyle.Normal); textPaint.SetTypeface(bold); bmp = Bitmap.CreateBitmap(w, h, Bitmap.Config.Argb8888); tmp = new Canvas(bmp); blueline = new Paint(PaintFlags.AntiAlias); blueline.StrokeWidth = 5; blueline.Color = Resources.GetColor(Resource.Color.dark_orange); blueline.SetStyle(Paint.Style.Stroke); tmp.DrawRect(0, 0, MeasuredWidth, MeasuredHeight, paint); }
public static Typeface get(string name, Context context) { Typeface tf = fontCache.GetValue(name); if (tf == null) { try { if (name.Equals("default")) { tf = Typeface.Default; } else { if (name.StartsWith("b_")) { tf = Typeface.Create(Typeface.CreateFromAsset(context.Assets, name.Substring(2)), TypefaceStyle.Bold); } else { tf = Typeface.CreateFromAsset(context.Assets, name); } } } catch (Exception e) { System.Console.WriteLine("FontCache get ERROR => " + e.Message); return(null); } fontCache[name] = tf; } return(fontCache[name]); }
public BasicPackageManagerView(Context context) : base(context, Resource.Drawable.icon_menu_round) { // Initialize & style Status label StatusLabel = new TextView(context); StatusLabel.SetTextColor(Color.Black); GradientDrawable background = new GradientDrawable(); background.SetCornerRadius(5); background.SetColor(Color.Argb(160, 255, 255, 255)); StatusLabel.Background = background; StatusLabel.Gravity = Android.Views.GravityFlags.Center; StatusLabel.Typeface = Typeface.Create("HelveticaNeue", TypefaceStyle.Normal); DisplayMetrics screen = Resources.DisplayMetrics; int width = screen.WidthPixels / 2; int height = width / 4; int x = screen.WidthPixels / 2 - width / 2; int y = screen.HeightPixels / 100; var parameters = new RelativeLayout.LayoutParams(width, height); parameters.TopMargin = y; parameters.LeftMargin = x; AddView(StatusLabel, parameters); Menu = new CityChoiceMenu(context); AddView(Menu); }
internal static Typeface ToTypeface(this Entry self) { if (self.IsDefault()) { return(_defaultTypeface ?? (_defaultTypeface = Typeface.Default)); } var key = new Tuple <string, FontAttributes>(self.FontFamily, self.FontAttributes); Typeface result; if (Typefaces.TryGetValue(key, out result)) { return(result); } if (self.FontFamily == null) { var style = ToTypefaceStyle(self.FontAttributes); result = Typeface.Create(Typeface.Default, style); } else if (Regex.IsMatch(self.FontFamily, LoadFromAssetsRegex)) { result = Typeface.CreateFromAsset(AApplication.Context.Assets, FontNameToFontFile(self.FontFamily)); } else { var style = ToTypefaceStyle(self.FontAttributes); result = Typeface.Create(self.FontFamily, style); } return(Typefaces[key] = result); }
public void SetTypeface(Typeface tf, TypefaceStyle style) { if (style > 0) { if (tf == null) { tf = Typeface.DefaultFromStyle(style); } else { tf = Typeface.Create(tf, style); } this.Typeface = tf; // now compute what (if any) algorithmic styling is needed TypefaceStyle typefaceStyle = tf != null ? tf.Style : TypefaceStyle.Normal; TypefaceStyle need = style & ~typefaceStyle; _textPaint.FakeBoldText = ((need & TypefaceStyle.Bold) != 0); _textPaint.TextSkewX = ((need & TypefaceStyle.Italic) != 0 ? -0.25f : 0); } else { _textPaint.FakeBoldText = false; _textPaint.TextSkewX = 0; this.Typeface = tf; } }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (e.NewElement != null) { var droidEditText = Control as EditText; droidEditText.SetHintTextColor(Xamarin.Forms.Color.White.ToAndroid()); Typeface font = Typeface.Create("Droid Sans Mono", TypefaceStyle.Normal); droidEditText.Typeface = font; } var customEntry = Element as StyledEntry; if (Control != null && customEntry != null) { SetKeyboardButtonType(customEntry.ReturnType); Control.EditorAction += (object sender, TextView.EditorActionEventArgs args) => { if (customEntry?.ReturnType != ReturnType.Next) { customEntry?.Unfocus(); } customEntry?.InvokeCompleted(); }; } }
public static Typeface ToTypeface(this Font self) { if (self.IsDefault || (self.FontAttributes == FontAttributes.None && string.IsNullOrEmpty(self.FontFamily))) { return(_sDefaultTypeface ?? (_sDefaultTypeface = Typeface.Default)); } var key = new Tuple <string, FontAttributes>(self.FontFamily, self.FontAttributes); if (Typefaces.TryGetValue(key, out var result)) { return(result); } if (self.FontFamily == null) { var style = ToTypefaceStyle(self.FontAttributes); result = Typeface.Create(Typeface.Default, style); } else { result = self.FontFamily.ToTypeFace(self.FontAttributes); } return(Typefaces[key] = result); }
void Initialize() { Clickable = true; Click += HandleClick; textSize = TypedValue.ApplyDimension(ComplexUnitType.Sp, 14, Resources.DisplayMetrics); spacing = TypedValue.ApplyDimension(ComplexUnitType.Dip, 24, Resources.DisplayMetrics); knobWidth = TypedValue.ApplyDimension(ComplexUnitType.Dip, 6, Resources.DisplayMetrics); knobPadding = TypedValue.ApplyDimension(ComplexUnitType.Dip, 2, Resources.DisplayMetrics); cornerRadius = TypedValue.ApplyDimension(ComplexUnitType.Dip, 2, Resources.DisplayMetrics); normalColor = Resources.GetColor(Resource.Color.dimmed_text_color); selectedColor = Resources.GetColor(Resource.Color.highlight_text_color); bgColor = Resources.GetColor(Resource.Color.primary_background); textPaint = new Paint { AntiAlias = true }; textPaint.SetTypeface(Typeface.Create("sans-serif-condensed", TypefaceStyle.Normal)); textPaint.TextSize = textSize; textPaint.TextAlign = Paint.Align.Center; textPaint.Color = normalColor; fontMetrics = textPaint.GetFontMetrics(); letterSpacing = fontMetrics.Bottom; ComputeCharacterSizes(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.GettingStarted); var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); SupportActionBar.Title = GetString(Resource.String.EditConfirmationTitle); SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); var dips_50 = TypedValue.ApplyDimension(ComplexUnitType.Dip, 50, Resources.DisplayMetrics); Grid = FindViewById <FlexGrid>(Resource.Id.Grid); Grid.GridLinesVisibility = GridLinesVisibility.None; Grid.HeadersGridLinesVisibility = GridLinesVisibility.None; Grid.HeadersVisibility = GridHeadersVisibility.Column; Grid.BackgroundColor = Color.White; Grid.RowBackgroundColor = ColorEx.FromARGB(0xFF, 0xE2, 0xEF, 0xDB); Grid.RowTextColor = Color.Black; Grid.AlternatingRowBackgroundColor = Color.White; Grid.ColumnHeaderBackgroundColor = ColorEx.FromARGB(0xFF, 0x70, 0xAD, 0x46); Grid.ColumnHeaderTextColor = Color.White; Grid.ColumnHeaderTypeface = Typeface.Create("", TypefaceStyle.Bold); Grid.SelectionBackgroundColor = ColorEx.FromARGB(0xFF, 0x5A, 0x82, 0x3F); Grid.SelectionTextColor = Color.White; Grid.DefaultRowHeight = new GridLength(dips_50); Grid.ItemsSource = Customer.GetCustomerList(100); Grid.BeginningEdit += OnBeginningEdit; Grid.CellEditEnded += OnCellEditEnded; }
public DrawableIcon() { try { settings = Settings.Instance; drawY = 1; drawX = 1; textSize = 10; typefaceDefault = Typeface.Create(Typeface.Monospace, TypefaceStyle.Normal); canvasResourceMaterial = Resource.Drawable.transparent32x32; colorText = Color.White; canvasColor = Color.Transparent; } catch (System.Exception ex) { #region Logging LogRuntimeAttribute.InLogFiles(typeof(DrawableIcon <T>), ex); #endregion } finally { } }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); if (e.PropertyName == CircleButton.BorderColorProperty.PropertyName || e.PropertyName == CircleButton.BorderThicknessProperty.PropertyName || e.PropertyName == CircleButton.IconProperty.PropertyName || e.PropertyName == CircleButton.TextProperty.PropertyName || e.PropertyName == CircleButton.FontIconProperty.PropertyName) { if (!String.IsNullOrEmpty(((CircleButton)Element).Icon)) { Control.Typeface = Typeface.CreateFromAsset(Forms.Context.Assets, Abstractions.Helpers.Extensions.FindNameFileForFont(((CircleButton)Element).FontIcon)); IIcon icon = Abstractions.Helpers.Extensions.FindIconForKey(((CircleButton)Element).Icon, ((CircleButton)Element).FontIcon); Element.Text = $"{icon.Character}"; } else { Control.Typeface = Typeface.Create(Element.FontFamily, TypefaceStyle.Normal); Element.Text = ((CircleButton)Element).Text; } this.Invalidate(); } }
internal static Typeface ToTypeface(this IFontElement self) { if (self.IsDefault()) { return(_sDefaultTypeface ?? (_sDefaultTypeface = Typeface.Default)); } var key = new Tuple <string, FontAttributes>(self.FontFamily, self.FontAttributes); if (Typefaces.TryGetValue(key, out var result)) { return(result); } if (self.FontFamily == null) { var style = ToTypefaceStyle(self.FontAttributes); result = Typeface.Create(Typeface.Default, style); } else if (IsAssetFontFamily(self.FontFamily)) { result = Typeface.CreateFromAsset(Android.App.Application.Context.Assets, FontNameToFontFile(self.FontFamily)); } else { var style = ToTypefaceStyle(self.FontAttributes); result = Typeface.Create(self.FontFamily, style); } return(Typefaces[key] = result); }
private void SetupAppearancePreferences() { String theme = PreferenceManager.GetDefaultSharedPreferences(this).GetString(GetString(Resource.String.pref_theme_key), EMPTY_STRING); String fontType = PreferenceManager.GetDefaultSharedPreferences(this).GetString(GetString(Resource.String.pref_font_choice_key), EMPTY_STRING); String fontSize = PreferenceManager.GetDefaultSharedPreferences(this).GetString(GetString(Resource.String.pref_font_size_key), EMPTY_STRING); if (!fontSize.Equals(EMPTY_STRING)) { Content.SetTextSize(Android.Util.ComplexUnitType.Sp, Single.Parse(fontSize)); } if (!fontType.Equals(EMPTY_STRING)) { Content.SetTypeface(Typeface.Create(fontType, TypefaceStyle.Normal), TypefaceStyle.Normal); } if (theme.Equals(GetString(Resource.String.theme_dark))) { Content.SetBackgroundColor(Resources.GetColor(Resource.Color.dark_grey)); Content.SetTextColor(Resources.GetColor(Android.Resource.Color.White)); keyboardBarView.SetBackgroundColor(Resources.GetColor(Resource.Color.grey)); } else { Content.SetBackgroundColor(Resources.GetColor(Android.Resource.Color.White)); Content.SetTextColor(Resources.GetColor(Resource.Color.dark_grey)); keyboardBarView.SetBackgroundColor(Resources.GetColor(Resource.Color.lighter_grey)); } }
public static Typeface TryGetFont(this Context context, string name, FontAttributes attr) { if (string.IsNullOrEmpty(name)) { return(Typeface.Default); } //Try to get font file based on font name string filename = null; _fontService.Fonts?.TryGetValue(name, out filename); //get folder containing fonts var fontFolder = _fontService?.FontFolder?.Path; //If we haven't found font in custom fonts, try to find it in system defaults if (filename == null || fontFolder == null) { return(Typeface.Create(name, attr.ToAndroid())); } //Create typeface from that font file var path = PortablePath.Combine(fontFolder, filename); var font = Typeface.CreateFromFile(new File(path)); return(font); }
public static Typeface ToTypeface(this Font self) { if (self.IsDefault || (self.FontAttributes == FontAttributes.None && string.IsNullOrEmpty(self.FontFamily))) { return(s_defaultTypeface ?? (s_defaultTypeface = Typeface.Default)); } var key = new Tuple <string, FontAttributes>(self.FontFamily, self.FontAttributes); Typeface result; if (Typefaces.TryGetValue(key, out result)) { return(result); } if (self.FontFamily == null) { var style = ToTypefaceStyle(self.FontAttributes); result = Typeface.Create(Typeface.Default, style); } else if (IsAssetFontFamily(self.FontFamily)) { result = Typeface.CreateFromAsset(AApplication.Context.Assets, FontNameToFontFile(self.FontFamily)); } else { var style = ToTypefaceStyle(self.FontAttributes); result = Typeface.Create(self.FontFamily, style); } return(Typefaces[key] = result); }
// Gets typeface, not using the cache // Accepts font names like "monospace" and font files like "myfile.ttf" // Also provides limited support for font paths like "myfile.ttf#myfont", converting them to "myfile.ttf" Typeface loadTypeface(string fontName) { if (fontName == null) { return(Typeface.Default); } bool isAsset = false; int poundIndex = fontName.IndexOf('#'); if (poundIndex > 0) { isAsset = true; fontName = fontName.Substring(0, poundIndex); } if (fontName.Contains(".")) { isAsset = true; } if (isAsset) { return(Typeface.CreateFromAsset(global::Android.App.Application.Context.Assets, fontName)); } else { return(Typeface.Create(fontName, TypefaceStyle.Normal)); } }
public virtual bool SetFont(string name, double size = 0) { var typeface = Typeface.Create(name, TypefaceStyle.Normal); FontName = name; return(SetTypeface(typeface)); }
protected override void OnDraw(Canvas canvas) { var metrics = Resources.DisplayMetrics; var widthInDp = ConvertPixelsToDp(metrics.WidthPixels); var heightInDp = ConvertPixelsToDp(metrics.HeightPixels); paintCircle.SetStyle(Paint.Style.Stroke); RectF rectF = new RectF(20, 20, this.Width - 20, this.Width - 20); paintCircle.AntiAlias = true; paintCircle.Color = Color.Rgb(124, 249, 0); paintCircle.StrokeWidth = 10; this.rectF = rectF; paintText.SetStyle(Paint.Style.FillAndStroke); paintText.StrokeWidth = 1; paintText.TextSize = this.Width / 4; paintText.AntiAlias = true; paintText.SetTypeface(Typeface.Create("Arial", TypefaceStyle.Italic)); paintText.Color = Color.Rgb(124, 249, 0); paintText.TextAlign = Paint.Align.Center; canvas.DrawArc(this.rectF, 270, -this.sweepAngle, false, this.paintCircle); canvas.DrawText(TimeString, this.Width / 2, this.Height / 2 + 50, this.paintText); }
private static void InitTypefaceWeightRamp() { // https://android.googlesource.com/platform/frameworks/base/+/master/data/fonts/fonts.xml lock (InitSyncObject) { if (null == TypefaceWeightRamp) { Typeface[] typefaceWeightRamp = new Typeface[5]; // Weight 100 if (global::Android.OS.Build.VERSION.SdkInt >= global::Android.OS.BuildVersionCodes.JellyBeanMr1) { typefaceWeightRamp[0] = Typeface.Create("sans-serif-thin", TypefaceStyle.Normal); // Weight=100 } else if (global::Android.OS.Build.VERSION.SdkInt >= global::Android.OS.BuildVersionCodes.JellyBean) { typefaceWeightRamp[0] = Typeface.Create("sans-serif-light", TypefaceStyle.Normal); // Weight=300 } else { typefaceWeightRamp[0] = Typeface.Create("sans-serif", TypefaceStyle.Normal); // Weight=400 } // Weight 300 if (global::Android.OS.Build.VERSION.SdkInt >= global::Android.OS.BuildVersionCodes.JellyBean) { typefaceWeightRamp[1] = Typeface.Create("sans-serif-light", TypefaceStyle.Normal); // Weight=300 } else { typefaceWeightRamp[1] = Typeface.Create("sans-serif", TypefaceStyle.Normal); // Weight=400 } // Weight 400 typefaceWeightRamp[2] = Typeface.Create("sans-serif", TypefaceStyle.Normal); // Weight=400 // Weight 500 if (global::Android.OS.Build.VERSION.SdkInt >= global::Android.OS.BuildVersionCodes.Lollipop) { typefaceWeightRamp[3] = Typeface.Create("sans-serif-medium", TypefaceStyle.Normal); // Weight=500 } else { typefaceWeightRamp[3] = Typeface.Create("sans-serif", TypefaceStyle.Bold); // Weight=700 } // Weight 700 typefaceWeightRamp[4] = Typeface.Create("sans-serif", TypefaceStyle.Bold); // Weight=700 TypefaceWeightRamp = typefaceWeightRamp; } } }
public ClockDial(PointF dialCenter, float textSize, Color textColor, float textRadius) { this.dialCenter = dialCenter; this.textRadius = textRadius; paint.TextSize = textSize; paint.Color = textColor; paint.SetTypeface(Typeface.Create("sans-serif", TypefaceStyle.Normal)); }
public CompassViewDrawer(IPoiCategoryBitmapProvider poiCategoryBitmapProvider) { Typeface normal = Typeface.Create("Arial", TypefaceStyle.Normal); this.poiCategoryBitmapProvider = poiCategoryBitmapProvider; paintRect = new Paint(); paintRect.SetARGB(150, 0, 0, 0); paintRect.SetStyle(Paint.Style.FillAndStroke); paintRect.StrokeWidth = 4; paintTapArea = new Paint(); paintTapArea.SetARGB(100, 0, 0, 0); paintTapArea.SetStyle(Paint.Style.Fill); paintTapFavourite = new Paint(); paintTapFavourite.SetARGB(150, 255, 195, 0); paintTapFavourite.SetStyle(Paint.Style.Fill); paintRectSelectedItem = new Paint(); paintRectSelectedItem.SetARGB(150, 255, 255, 255); paintRectSelectedItem.SetStyle(Paint.Style.FillAndStroke); paintRectSelectedItem.StrokeWidth = 4; textpaint = new Paint(); textpaint.SetARGB(255, 200, 255, 0); textpaint.TextSize = 36; textpaint.AntiAlias = true; textpaint.SetTypeface(normal); textpaintSelected = new Paint(); textpaintSelected.SetARGB(255, 0, 0, 0); textpaintSelected.TextSize = 36; textpaintSelected.AntiAlias = true; textpaintSelected.SetTypeface(normal); textPaintForEllipsize = new TextPaint(); textPaintForEllipsize.SetARGB(255, 200, 255, 0); textPaintForEllipsize.SetStyle(Paint.Style.Fill); textPaintForEllipsize.TextSize = 36; textPaintForEllipsize.AntiAlias = true; textPaintForEllipsize.TextAlign = Paint.Align.Left; textPaintForEllipsize.LinearText = true; paintWhite = new Paint(); paintWhite.SetARGB(255, 255, 255, 255); paintWhite.SetStyle(Paint.Style.Fill); paintGray = new Paint(); paintGray.SetARGB(255, 186, 186, 186); paintGray.SetStyle(Paint.Style.Fill); paintBlack = new Paint(); paintBlack.SetARGB(255, 0, 0, 0); paintBlack.SetStyle(Paint.Style.Fill); multiplier = 1; }
public void Update() { if (Node == null) { // The node is "Table of Contents" llDivider.Visibility = ViewStates.Invisible; ivIcon.Visibility = ViewStates.Invisible; llLevelMark.SetBackgroundColor(GetColor()); tvTitle.SetTextSize(Android.Util.ComplexUnitType.Sp, 14); tvTitle.Typeface = Typeface.Create( MainApp.ThisApp.Resources.GetString(Resource.String.FontFamily_Roboto_Medium), TypefaceStyle.Bold); tvTitle.Text = MainApp.ThisApp.Resources.GetString(Resource.String.TOCPanel_TableOfContents); tvTitle.SetTextColor(DefaultTOCTextColor); llBackground.SetBackgroundColor(DefaultBackgroundColor); } else { llDivider.Visibility = ViewStates.Visible; ivIcon.Visibility = ViewStates.Visible; llLevelMark.SetBackgroundColor(GetColor()); tvTitle.SetTextSize(Android.Util.ComplexUnitType.Sp, 16); tvTitle.Typeface = Typeface.Create( MainApp.ThisApp.Resources.GetString(Resource.String.FontFamily_Roboto_Regular), TypefaceStyle.Normal); tvTitle.Text = Node.Title; if (Node.IsParent()) { ivIcon.SetImageResource( DataCache.INSTATNCE.Toc.IsExpanded(Node, adaptor.NodeList) ? Resource.Drawable.toc_expanded : Resource.Drawable.toc_collaped); } else { ivIcon.SetImageResource( DataCache.INSTATNCE.Toc.IsCurrentNode(Node) ? Resource.Drawable.toc_page_white : Resource.Drawable.toc_page_grey); } if (DataCache.INSTATNCE.Toc.IsCurrentNode(Node)) { tvTitle.SetTextColor(CurrentTOCTextColor); llBackground.SetBackgroundColor(GetColor()); } else { tvTitle.SetTextColor(DefaultTOCTextColor); llBackground.SetBackgroundColor(DefaultBackgroundColor); } } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); AndroidExtensions.Initialize(this); SetContentView(Resource.Layout.Main); this.drawer = FindViewById <DrawerLayout> (Resource.Id.drawer_layout); this.drawerToggle = new MoyeuActionBarToggle(this, drawer, Resource.Drawable.ic_drawer, Resource.String.open_drawer, Resource.String.close_drawer) { OpenCallback = () => { ActionBar.Title = Title; CurrentFragment.HasOptionsMenu = false; InvalidateOptionsMenu(); }, CloseCallback = () => { var currentFragment = CurrentFragment; if (currentFragment != null) { ActionBar.Title = ((IMoyeuSection)currentFragment).Title; currentFragment.HasOptionsMenu = true; } InvalidateOptionsMenu(); }, }; drawer.SetDrawerShadow(Resource.Drawable.drawer_shadow, (int)GravityFlags.Left); drawer.SetDrawerListener(drawerToggle); ActionBar.SetDisplayHomeAsUpEnabled(true); ActionBar.SetHomeButtonEnabled(true); Hubway.Instance.Subscribe(this); FavoriteManager.FavoritesChanged += (sender, e) => aroundAdapter.Refresh(); drawerMenu = FindViewById <ListView> (Resource.Id.left_drawer); drawerMenu.AddFooterView(new Space(this)); drawerMenu.ItemClick += HandleSectionItemClick; menuNormalTf = Typeface.Create(Resources.GetString(Resource.String.menu_item_fontFamily), TypefaceStyle.Normal); menuHighlightTf = Typeface.Create(Resources.GetString(Resource.String.menu_item_fontFamily), TypefaceStyle.Bold); drawerMenu.Adapter = new DrawerMenuAdapter(this); drawerAround = FindViewById <ListView> (Resource.Id.left_drawer_around); drawerAround.ItemClick += HandleAroundItemClick; drawerAround.Adapter = aroundAdapter = new DrawerAroundAdapter(this); drawerMenu.SetItemChecked(0, true); if (CheckGooglePlayServices()) { client = CreateApiClient(); SwitchTo(mapFragment = new HubwayMapFragment(this)); ActionBar.Title = ((IMoyeuSection)mapFragment).Title; } }
ViewGroup DrawTemplate(Node node) { //TEMPLATE var template = new Shape(this, diagram.Context, node, dataModel, FillColor, StrokeColor); template.Layout(0, 0, (int)node.Width, (int)node.Height); //EMP IMAGE var img = new ImageView(diagram.Context); var imageId = (node.Content as DiagramEmployee).ImageUrl; if (imageId != null) { var imageData = LoadResource(imageId).ToArray(); img.SetImageBitmap(BitmapFactory.DecodeByteArray(imageData, 0, imageData.Length)); } img.SetPadding(0, (int)(10 * MainActivity.factor), 0, 0); img.Layout((int)(10 * MainActivity.factor), (int)(10 * MainActivity.factor), (int)(100 * MainActivity.factor), (int)(100 * MainActivity.factor)); //Name of the employee. var name = new TextView(diagram.Context); name.Text = (node.Content as DiagramEmployee).Name; name.SetTextSize(Android.Util.ComplexUnitType.Px, 28 * MainActivity.factor); name.SetTextColor(Color.White); name.SetPadding(0, (int)(10 * MainActivity.factor), 0, 0); name.Layout((int)(110 * MainActivity.factor), (int)(10 * MainActivity.factor), (int)node.Width, (int)node.Height); //Designation of the employee. var designation = new TextView(diagram.Context); designation.Text = (node.Content as DiagramEmployee).Designation; designation.SetTextSize(Android.Util.ComplexUnitType.Px, 28 * MainActivity.factor); designation.SetTextColor(Color.White); designation.SetPadding(0, (int)(10 * MainActivity.factor), 0, 0); designation.Layout((int)(110 * MainActivity.factor), (int)(50 * MainActivity.factor), (int)node.Width, (int)node.Height); if ((node.Content as DiagramEmployee).HasChild) { expanded = new ExpandButton(diagram.Context, node, FillColor); template.SetExpanded(expanded); expanded.Text = "-"; expanded.Typeface = Typeface.Create("Times New Roman", TypefaceStyle.Bold); expanded.TextAlignment = TextAlignment.Center; expanded.Gravity = GravityFlags.Center; expanded.SetTextSize(Android.Util.ComplexUnitType.Px, 54 * MainActivity.factor); expanded.SetTextColor(Color.White); expanded.SetPadding(0, (int)(10 * MainActivity.factor), 0, 0); expanded.SetColor(template.m_color); expanded.SetStrokeColor(template.m_strokeColor); expanded.Layout((int)(350 * MainActivity.factor), 0, (int)(node.Width - 10 * MainActivity.factor), (int)node.Height); template.AddView(expanded); } //Add the view to the template instance. template.AddView(img); template.AddView(name); template.AddView(designation); return(template); }
void InitStepCountPaint() { stepcountPaint = new Paint(); //stepcountPaint.Color = Color.White; stepcountPaint.SetARGB(255, 50, 151, 218); stepcountPaint.SetTypeface(Typeface.Create(Typeface.SansSerif, TypefaceStyle.Normal)); stepcountPaint.AntiAlias = true; stepcountPaint.TextSize = owner.Resources.GetDimension(Resource.Dimension.StepCountTextSize); }