void InitToolBarMiddleText(string text, Color color) { var toolbar = FatherToolbar; if (toolbar != null) { string toolbarTitle = text; var layoutPara = new Android.Support.V7.Widget.Toolbar.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent, 1); if (initTextView != null) { toolbar.RemoveView(initTextView); } initTextView = new TextView(Forms.Context) { LayoutParameters = layoutPara, Gravity = GravityFlags.Center, Text = toolbarTitle, TextSize = 18, }; initTextView.SetSingleLine(); initTextView.SetTextColor(color.ToAndroid()); toolbar.AddView(initTextView); toolbar.Title = ""; GetCurrentPage().Title = ""; } }
void UpdateToolBarMiddleText(string text) { var toolbar = FatherToolbar; if (toolbar != null && initTextView != null) { initTextView.Text = text; toolbar.Title = "";//这样就看不到左边的Title了 } else { var layoutPara = new Android.Support.V7.Widget.Toolbar.LayoutParams( LayoutParams.WrapContent, LayoutParams.WrapContent, 1); initTextView = new TextView(Forms.Context) { LayoutParameters = layoutPara, Gravity = GravityFlags.Center, Text = text, TextSize = 20, }; initTextView.SetSingleLine(); initTextView.SetTextColor(Android.Graphics.Color.White); toolbar.AddView(initTextView); toolbar.Title = ""; } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); try{ viewModel = ServiceContainer.Resolve <DetailsViewModel> (); } catch { viewModel = new DetailsViewModel(); ServiceContainer.RegisterScoped(viewModel); } adapter = new DetailsAdapter(this, SupportFragmentManager, viewModel); pager = FindViewById <ViewPager> (Resource.Id.pager); var tabs = FindViewById <TabLayout> (Resource.Id.tabs); pager.Adapter = adapter; tabs.SetupWithViewPager(pager); pager.OffscreenPageLimit = 3; var layoutParameters = new Android.Support.V7.Widget.Toolbar.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent, (int)(GravityFlags.Top | GravityFlags.Right)); var progressBar = new ProgressBar(this, null, Android.Resource.Attribute.ProgressBarStyleSmallTitle) { Indeterminate = true, LayoutParameters = layoutParameters }; SupportActionBar.SetDisplayShowCustomEnabled(true); SupportActionBar.CustomView = progressBar; SupportActionBar.Title = viewModel.Place == null ? string.Empty : viewModel.Place.Name; #if !DEBUG Xamarin.Insights.Track("AppNav", new Dictionary <string, string> { { "page", "details" }, { "name", SupportActionBar.Title } }); #endif client = new GoogleApiClientBuilder(this) .AddConnectionCallbacks(this) .EnableAutoManage(this, 0, this) .AddApi(AppInviteClass.API) .Build(); }
void InitToolBarMiddleText() { var toolbar = FatherToolbar; if (toolbar != null) { string toolbarTitle = "TiTle"; var layoutPara = new Android.Support.V7.Widget.Toolbar.LayoutParams( LayoutParams.WrapContent, LayoutParams.WrapContent, 1); initTextView = new TextView(Forms.Context) { LayoutParameters = layoutPara, Gravity = GravityFlags.Center, Text = toolbarTitle, TextSize = 20, }; initTextView.SetTextColor(Android.Graphics.Color.White); toolbar.AddView(initTextView); toolbar.Title = ""; } }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); try{ viewModel = ServiceContainer.Resolve<DetailsViewModel> (); } catch{ viewModel = new DetailsViewModel (); ServiceContainer.RegisterScoped (viewModel); } adapter = new DetailsAdapter (this, SupportFragmentManager, viewModel); pager = FindViewById<ViewPager> (Resource.Id.pager); var tabs = FindViewById<TabLayout> (Resource.Id.tabs); pager.Adapter = adapter; tabs.SetupWithViewPager (pager); pager.OffscreenPageLimit = 3; var layoutParameters = new Android.Support.V7.Widget.Toolbar.LayoutParams ( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent, (int)(GravityFlags.Top | GravityFlags.Right)); var progressBar = new ProgressBar (this, null, Android.Resource.Attribute.ProgressBarStyleSmallTitle) { Indeterminate = true, LayoutParameters = layoutParameters }; SupportActionBar.SetDisplayShowCustomEnabled (true); SupportActionBar.CustomView = progressBar; SupportActionBar.Title = viewModel.Place == null ? string.Empty : viewModel.Place.Name; #if !DEBUG Xamarin.Insights.Track ("AppNav", new Dictionary<string,string> { { "page", "details" }, { "name", SupportActionBar.Title } }); #endif client = new GoogleApiClientBuilder (this) .AddConnectionCallbacks (this) .EnableAutoManage (this, 0, this) .AddApi (AppInviteClass.API) .Build (); }