2017-02-14 11 views
2

ログイン後にマップ上のユーザーの位置を指すシンプルなジオローカライゼーションアプリケーションを構築しようとしています。この部分はうまく動作しますが、ステータスバーとビューから削除したい空白がありますが、どのように表示されているのか分かりません。StatusBarとMasterDetailPageの間に白いバーが表示されます。Xamarin.Forms Android

enter image description here

enter image description here

私はすでにここで紹介するソリューションを試みた:https://forums.xamarin.com/discussion/86568/unwanted-blank-space-above-navigation-bar-navigation-page を、それがうまく動作しませんでした:XAMLソリューションはdidnのここ

は、バグの画面に2つのリンクがあります何もしないで、最後の解決策(ビルドバージョンのチェック付き)は、青いバーも消滅させました。これは調査された効果ではありません。

私は私の地図を表示ページ::ここで

は、私のコードの一部、あなたがより多くのものを必要とするなら、私に教えている

<?xml version="1.0" encoding="utf-8" ?> 
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
      xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
      x:Class="MyApp.View.Detail" 
      xmlns:i18n="clr-namespace:MyApp" 
      Title="" 
      BackgroundColor="{StaticResource MainBackgroundColor}" 
      xmlns:maps="clr-namespace:Xamarin.Forms.Maps;assembly=Xamarin.Forms.Maps"> 
    <StackLayout> 
    <ActivityIndicator IsRunning="{Binding IsBusy, Mode=TwoWay}" IsVisible="{Binding IsBusy, Mode=TwoWay}" Color="Blue"/> 
    <maps:Map VerticalOptions ="FillAndExpand" HorizontalOptions ="FillAndExpand" 
      x:Name="MyMap" 
      IsShowingUser="true" 
      MapType="Street" 
     /> 
    </StackLayout> 
</ContentPage> 

そして、ここではMasterViewDetail

<?xml version="1.0" encoding="utf-8" ?> 
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms" 
      xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
      x:Class="MyApp.View.HomePage"> 

</MasterDetailPage> 

ですご協力ありがとうございました!

編集:ここでは

は私のプロジェクトの構造である:

App(NavigationPage) 
    MainPage (ContentPage) 
     LoginPage (ContentPage) 
      HomePage (MasterDetailPage) 
       HomeDetail(ContentPage) 
     RegisterPage (ContentPage) 

問題は、私はインターンだと、クライアントのコマンドに従わなければならない、私はそれで完全に無料ではないよ..です

+0

あなた 'MainPage'の設定は何ですか?それは 'NavigationPage'ですか?もしそうなら、それが 'MasterDetailPage'になるように変更し、マスター&ディテールは代わりに' NavigationPage'sでなければなりません。 – Krumelur

答えて

2

これはXamarinフォームの中にそのように構築されています。常にトップパディングを追加します。このためにバグが発生しましたが、修正時期はわかりません。

私はいくつかのハック反射を行うカスタムレンダラでそれを回避するために管理してきました:

[assembly: ExportRenderer(typeof(MasterDetailPage), typeof(NoSpaceMasterDetailPageRenderer))] 

namespace Droid.Renderers 
{ 
    public class NoSpaceMasterDetailPageRenderer : MasterDetailPageRenderer 
    { 
     /// <summary> 
     /// When adding a view, tweak the top padding if necessary. 
     /// According to: 
     /// https://github.com/xamarin/Xamarin.Forms/blob/589adbd3ef145ec85f9fe64eda008251c1cdb745/Xamarin.Forms.Platform.Android/AppCompat/MasterDetailPageRenderer.cs 
     /// The TopPadding is always set for the detail. This works fine when the master detail is shown normally, but 
     /// if it is inside a navigation page (such as the inspection view) then you get extra unwanted padding. 
     /// The 'fix' is to set the top padding to 0 for the detail, only of course the types and fields are hidden from us... 
     /// </summary> 
     /// <param name="child">Child.</param> 
     public override void AddView(Android.Views.View child) 
     { 
      try 
      { 
       var isMasterField = child.GetType().GetField("_isMaster", BindingFlags.NonPublic | BindingFlags.Instance); 
       if (isMasterField == null) return; 

       var isMaster = isMasterField.GetValue(child); 
       if ((bool)isMaster) return; 

       var parentField = child.GetType().GetField("_parent", BindingFlags.NonPublic | BindingFlags.Instance); 
       if (parentField == null) return; 

       var parent = parentField.GetValue(child) as MasterDetailPage; 
       if (parent == null || !(parent.Parent is NavigationPage)) return; 

       var topPaddingProperty = child.GetType().GetProperty("TopPadding", BindingFlags.Public | BindingFlags.Instance); 
       if (topPaddingProperty != null) 
        topPaddingProperty.SetValue(child, 0); 
      } 
      finally 
      { 
       base.AddView(child); 
      } 
     } 
    } 
} 
+0

また、Formsでネガティブパッドを直接設定することもできます。多分レンダラの必要はありません。 – Krumelur

+0

私はネガティブパッドを試しましたが、ナビゲーションバーの下にある空白に干渉することなくコンテンツをプッシュしました。 [リンク](http://i.imgur.com/Q5XOTFU.png) –

+0

また@JimBobBennett、私はあなたの答えに非常に興味がありますが、私はそれがどのように使われるべきかをよく理解していません...私はレンダラーはプラットフォームを扱うので、Androidプロジェクト(ポータブルプロジェクトではない)に配置する必要がありますが、どのように使用しますか? –

関連する問題