如何删除<NavigationPage.TitleView>
Xamarin.Forms 周围的丑陋蓝色空间?
<NavigationPage.TitleView>
<StackLayout Orientation="Horizontal" Margin="0" Spacing="0" Style="{StaticResource BkGroundToolbarStyle}">
...
</StackLayout>
</NavigationPage.TitleView>
我已经测试了这篇文章:Wendy Zang - MSFT,但正如你所见,它对我不起作用。这是Toolbar.xml
我的Android项目中文件的内容:
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
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"
android:contentInsetLeft="0dp"
android:contentInsetRight="0dp"
android:contentInsetStart="0dp"
android:contentInsetEnd="0dp"
android:contentInsetStartWithNavigation="0dp"
android:paddingLeft="0dp"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:contentInsetRight="0dp"
app:contentInsetEnd="0dp"
/>
我也尝试了这个解决方案:Mauro Cavallin - Lemcube但我得到一个错误:'V7' doesn't exist in the namespace 'Android.Support' in this line:
var toolbar = this.FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
你如何成功?或者你为什么没有同样的问题?
编辑:感谢 Cherry Bu - MSFT 解决方案,我可以删除左边的空间。但是上面和下面的两条线仍然存在。
这可能是由于Xamarin 中的 BAD Height 计算导致的吗?这是我的工具栏的定义:
<NavigationPage.TitleView>
<StackLayout Style="{DynamicResource ToolbarBkGrndColorStyle}"
Orientation="Horizontal" Margin="0" Spacing="0" Padding="0"
HorizontalOptions="Fill" VerticalOptions="Fill">
...
</StackLayout>
</NavigationPage.TitleView>
如果我用这个替换stacklayout的定义,问题就会消失(但我的内容不再可见......):
<StackLayout Style="{DynamicResource ToolbarBkGrndColorStyle}"
Orientation="Horizontal" Margin="0" Spacing="0" Padding="0"
HorizontalOptions="FillAndExpand" HeightRequest="1000">
那么,我应该如何定义这个 Stacklayout 的高度???