我有一个主页,我在其中创建了自定义工具栏,现在我需要向其中添加菜单项。到目前为止我已经成功了并且我有我的search
图标在app:showAsAction="always"
模式(白色)但是当我添加任何东西时app:showAsAction="never"
模式下,菜单指示器(三个点)显示为黑色,但我希望它们是白色的。
AndroidManifest.xml
<activity
android:name=".HomePage"
android:launchMode="singleTask" />
actvity_homepage.xml
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintVertical_bias="0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
app:titleTextColor="#ffffff"
style="@style/ToolbarTheme"
android:textAlignment="textStart"
android:background="#2B772E"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
homepage_menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/logoutmenu"
android:title= "Log Out"
android:icon="@drawable/logout"
app:itemIconTint = "#ffffff"
app:showAsAction="never"/>
<item
android:id="@+id/search"
android:icon="@drawable/search"
app:showAsAction="always"
android:title="Hello" />
</menu>
(第一种方式)按照您的风格:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
...
<item name="actionOverflowButtonStyle">@style/MyOverflowButtonStyle</item>
</style>
<style name="MyOverflowButtonStyle" parent="Widget.AppCompat.ActionButton.Overflow">
<item name="android:tint">#62ff00</item>
</style>
或者您可以使用工具栏样式更改它,如下所示:
<android.support.v7.widget.Toolbar
...
theme="@style/MyToolbarStyle"
/>
并以您的风格:
<style name="MyToolbarStyle" parent="ThemeOverlay.AppCompat.ActionBar">
<item name="android:textColorSecondary">#333333</item>
</style>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)