我有一个工具栏,我想将背景更改为黑色,但是默认情况下项目的颜色为黑色,并且我想将其颜色更改为灰色,我该怎么做?非常感谢:
My Image about Toolbar

这是我的toolbar.xml

<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#2196F3"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">




我的styles.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

最佳答案

创建图标或矢量资产时,可以选择颜色

android - 如何更改工具栏上项目的颜色-LMLPHP

单击颜色选择器。

如果要更改代码中的颜色,请在MenuItem中添加app:iconTint="@color/yourcolor"来更改图标颜色。

<item
android:icon="@drawable/ic_share_white_24dp"
android:id="@+id/action_share"
android:title="@string/action_share"
android:orderInCategory="200"
app:iconTint="@color/yourcolor"
app:showAsAction="ifRoom"
app:actionProviderClass="android.support.v7.widget.ShareActionProvider"/>


要更改3点图标的颜色,请尝试在styles.xml中添加

<style name="YourCustomTheme.OverFlow">
    <item name="android:src">@drawable/my_overflow_image</item>
</style>

关于android - 如何更改工具栏上项目的颜色,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/56380549/

10-11 22:39
查看更多