2016-08-24 15 views
0

Xamarin.Formsを使用すると、以下の図に示すアプリケーションと同じ効果を得ることができます。具体的には、アクションバー/ページツールバー(青色のセクションボックス)? このセクションには幅の広い画像が必要ですが、ソリューションはAndroid、iOS、Windows Phone、およびユニバーサルWindows(カスタムレンダラーやプラットフォーム固有のxamarinコードの作成を意味する場合でも)で動作する必要があります。Xamarin.Formsアクションバー - 中央整列イメージ

enter image description here

+2

あなたはそれぞれのネイティブプロジェクトであなたのアクションバー/タイトルバーをカスタマイズする必要があります。クロスプラットフォームソリューションはありません。その1ページだけの場合は、ナビゲーションタイトルバーを非表示にして、その中に必要なアイテムを含むレイアウトを表示することができます。 –

答えて

0

私はあなたがあなた自身のXamarin.Formsビューを作成して、自分でこれと似たようなナビゲーションを扱うお勧め:

public class CustomBackNavigationBar : StackLayout 
{ 
    public Image BackIcon; 
    public Image Icon; 
    public Label IconTitle; 
    public StackLayout IconContainer; 

    public CustomBackNavigationBar(string title, string icon) 
    { 
     Padding = new Thickness(15,5); 
     HeightRequest = 40; 
     Orientation = StackOrientation.Horizontal; 
     VerticalOptions = LayoutOptions.Start; 
     BackgroundColor = StaticData.BlueColor; 
     Spacing = 15; 

     BackIcon = new Image 
     { 
      Source = StaticData.BackIcon, 
      HorizontalOptions = LayoutOptions.Start 
     }; 

     Label Title = new Label 
     { 
      Text = title, 
      TextColor = Color.White, 
      FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)), 
      FontAttributes = FontAttributes.Bold, 
      VerticalTextAlignment = TextAlignment.Center 
     }; 

     Icon = new Image 
     { 
      Source = icon 
     }; 

     IconTitle = new Label 
     { 
      Text = StaticData.CallAgent, 
      TextColor = Color.White, 
      FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label)), 
     }; 

     IconContainer = new StackLayout 
     { 
      HorizontalOptions = LayoutOptions.EndAndExpand, 
      Spacing = 2, 
      Children = { Icon, IconTitle } 
     }; 

     Children.Add(BackIcon); 
     Children.Add(Title); 
     Children.Add(IconContainer); 

     #region Events 

     BackIcon.GestureRecognizers.Clear(); 
     BackIcon.GestureRecognizers.Add(new TapGestureRecognizer 
     { 
      Command = new Command(PopAsync) 
     }); 

     #endregion 

    } 

    async void PopAsync() 
    { 
     await App.AppNavigation.PopAsync(); 
    } 
} 
関連する問題