gpt4 book ai didi

android - Xamarin 表格 : How to change Toolbar height in Android?

转载 作者:太空宇宙 更新时间:2023-11-03 13:42:35 25 4
gpt4 key购买 nike

我有一个使用工具栏的 XF 应用程序,它被添加到我的 ContentPage 中,如下所示:

public HomePage()
{
InitializeComponent();
var toolbarItem = new ToolbarItem
{
Text="Item1",
Priority = 0,
Order = ToolbarItemOrder.Primary,
};

if(Device.RuntimePlatform == Device.Android) {
this.ToolbarItems.Add(toolbarItem);
}
}

我想将工具栏的高度更改为小于原始高度。我编辑了 Toolbar.axml 如下:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/AppToolbarTheme"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="50dp"
android:minHeight="0dp"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways" />

不幸的是,这没有任何效果。还有其他方法可以更改工具栏高度吗?

最佳答案

在您的 Android 项目中,在您的 style.xml 文件中添加一个名为 android:actionBarSize 的项目,如下所示:

<?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>

<!-- ********* CHECK HERE ********* -->
<item name="android:actionBarSize">250dp</item>
</style>

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

关于android - Xamarin 表格 : How to change Toolbar height in Android?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48767775/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com