I did this xaml in my toolbar
<?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/colorPrimary" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" android:popupTheme="@style/ThemeOverlay.AppCompat.Light"> <LinearLayout android:id="@+id/alternateTitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="start" android:id="@+id/toolbarIcon" /> <TextView android:id="@+id/alternateTitle1" android:text="" android:textSize="@dimen/notification_subtext_size" android:textColor="@color/material_deep_teal_500" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" /> <TextView android:id="@+id/alternateTitle2" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> </android.support.v7.widget.Toolbar>
and then i did this renderer
[assembly: ExportRenderer(typeof(NavigationPage), typeof(NavigationRenderer))] namespace Operacional.Droid { public class NavigationRenderer : NavigationPageRenderer { private Support.Toolbar _toolbar; public override void OnViewAdded(Android.Views.View child) { base.OnViewAdded(child); if (child.GetType() == typeof(Support.Toolbar)) _toolbar = (Support.Toolbar)child; } protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); var page = this.Element as NavigationPage; if (page != null && _toolbar != null) { Typeface tf = Typeface.CreateFromAsset(Android.App.Application.Context.Assets, "Arial.ttf"); TextView title = (TextView)_toolbar.FindViewById(Resource.Id.alternateTitle1); title.SetText(page.CurrentPage.Title, TextView.BufferType.Normal); title.SetTypeface(tf, TypefaceStyle.Normal); title.Text = "Paulo Correa"; } } } }
and how can i make to work this renderer? How can i changes text, font, size and so on? How do i call the renderer in my project? Do i call in the App.cs or where?
i'm reading this
https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/custom-renderer/
Answers
How do i call a renderer? How do i do work?