我有一个使用工具栏的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" 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项目中,添加一个名为androID:actionbarSize的项目,并将其高度添加到style.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> <!-- ********* CHECK HERE ********* --> <item name="androID:actionbarSize">250dp</item> </style> <style name="AppCompatDialogStyle" parent="theme.AppCompat.light.Dialog"> <item name="colorAccent">#FF4081</item> </style></resources>
总结 以上是内存溢出为你收集整理的Xamarin Forms:如何在Android中更改工具栏高度?全部内容,希望文章能够帮你解决Xamarin Forms:如何在Android中更改工具栏高度?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)