首页 文章

更改Xamarin表单NavigationPage工具栏的高度

提问于
浏览
4

我正在尝试更改使用AppCompat在Android上呈现的Xamarin表单工具栏的高度 . 从Forms中没有高度属性来设置这个,所以我试图在 toolbar.axml 中设置 layout_height ,如下所示

<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="128dp"
    android:minHeight="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    app:layout_scrollFlags="scroll|enterAlways" />

这不会改变高度 .

我也尝试过设置

  • android:minHeight

  • android:身高

  • 身高

  • android:actionBarSize

但那些也不会改变高度 .

FWIW,当使用带有ActionBar的Xamarin Forms非AppCompat NavigationPage时,我能够使用 android:height 设置高度 .

1 回答

  • 3

    我发现下面对同样的问题非常有帮助 .

    Xamarin Forms: How to change Toolbar height in Android?

    • <item name="android:actionBarSize">250dp</item> 添加到styles.xml中

    • 从Toolbar.axml中删除 android:layout_height="wrap_content" .

    这可以让您定义导航栏所需的任何高度 .

    希望有所帮助

相关问题