xamarin.forms - 如何将母版页菜单内容显示在导航栏下方?

标签 xamarin.forms navigation-drawer master-detail

我在使用 xamarin 形式的导航页面设计主从页面样式时遇到一个小问题。

母版页的内容占据设备的整个高度。我希望内容从导航栏底部显示。

这是母版页的示例:

<?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="XamarinExp.Pages.SampleMasterPage">
  <MasterDetailPage.Master>
    <ContentPage Title="Menu">
      <StackLayout Spacing="0">
        <Label Text="Sample Menu" FontSize="Large" FontAttributes="Bold"></Label>
        <ListView x:Name="lvMenu" SeparatorColor="Green">
          <ListView.ItemTemplate>
            <DataTemplate>
              <ViewCell>
                <StackLayout Padding="10,0,0,0">
                  <Label HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" YAlign="Center" Text="{Binding Title}" TextColor="#03a9f4" >
                    <Label.GestureRecognizers>
                      <TapGestureRecognizer Tapped="OnLabelClicked" />
                    </Label.GestureRecognizers>
                  </Label>
                </StackLayout>
              </ViewCell>
            </DataTemplate>
          </ListView.ItemTemplate>
        </ListView>
      </StackLayout>
    </ContentPage>
  </MasterDetailPage.Master>
</MasterDetailPage>

cs 文件中的代码片段:

NavigationPage nPage = new NavigationPage(new DeviceCheck());
this.Detail = nPage;

这就是我在 Droid/Resources/values/styles.xml 中的内容

<?xml version="1.0" encoding="utf-8" ?>
<resources>

  <style name="MainTheme" parent="MainTheme.Base">
  </style>
  <!-- Base theme applied no matter what API -->
  <style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
    <item name="windowNoTitle">true</item>
    <!--We will be using the toolbar so no need to show ActionBar-->
    <item name="windowActionBar">false</item>
    <!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette -->
    <!-- colorPrimary is used for the default action bar background -->
    <item name="colorPrimary">#2196F3</item>
    <!-- colorPrimaryDark is used for the status bar -->
    <item name="colorPrimaryDark">#1976D2</item>
    <!-- colorAccent is used as the default value for colorControlActivated
         which is used to tint widgets -->
    <item name="colorAccent">#FF4081</item>
    <!-- You can also set colorControlNormal, colorControlActivated
         colorControlHighlight and colorSwitchThumbNormal. -->
    <item name="windowActionModeOverlay">true</item>

    <item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>

    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
  </style>

  <style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
    <item name="colorAccent">#FF4081</item>
  </style>
</resources>

我希望菜单从蓝色条下方开始。

任何帮助表示赞赏。提前致谢。

最佳答案

在App.cs中设置NavigationPage类型的MainPage

 MainPage = new NavigationPage(new SampleMasterPage());

关于xamarin.forms - 如何将母版页菜单内容显示在导航栏下方?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41846223/

相关文章:

android - 是否可以更改 Xamarin.Forms(可移植)中条目的底部边框

android - 用户登录时更改 NavigationView 项目

mysql - 如何通过 NOT IN 过滤主明细表?

android - 具有主/详细流程的 fragment 中的可扩展 ListView

ios - 使用 Xamarin.Forms 在 iOS NavigationBar 中显示 "Back to Menu"按钮

c# - xamarin.droid 中 UITest 的引用问题

xamarin.forms - 如何使用 XAML 在 ListView 中实现 ItemTemplate

java - 当导航栏打开时,MainActivity 仍然可点击

php - 使用Services PHP/Mysql Xamarin登录失败

android - 抽屉导航 : Add Titles to Groups, 不是项目