Android 更改操作提供程序返回图标

Android 更改操作提供程序返回图标,android,icons,Android,Icons,操作提供程序返回图标: 如何更改操作提供程序生成的后退图标。 我已经在使用HomeAsUpIndicator的所有活动中更改了back图标。 但这个生成的返回图标仍然带有默认的黑色箭头。 上面的图片显示了我谈论的图标,例如当我点击搜索图标时 在我的活动中: Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_equipment); setSupportActionBar(toolbar); getSupportAction

操作提供程序返回图标:

如何更改操作提供程序生成的后退图标。 我已经在使用HomeAsUpIndicator的所有活动中更改了back图标。 但这个生成的返回图标仍然带有默认的黑色箭头。 上面的图片显示了我谈论的图标,例如当我点击搜索图标时

在我的活动中:

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_equipment);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_chevron_left_white_48dp);
[……]


编辑
styles.xml
并添加以下内容:

<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
    <item name="android:actionBarStyle">@style/CustomActionBar</item>
</style>

<style name="CustomActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
    <item name="android:icon">@drawable/ic_close</item>
</style>

@样式/自定义操作栏
@可抽出式/集成电路关闭

获取SupportActionbar并指定图标的id

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_close);

它适用于以下行:

app:collapseIcon="@drawable/ic_chevron_left_white_48dp"
放在这里:

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar_equipment"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    app:title="@string/equipments"
    app:titleTextColor="@color/white"
    android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    app:collapseIcon="@drawable/ic_chevron_left_white_48dp" />


还是一样,但我使用的是NoActionBar主题,这是一个问题?我在活动中已经这样做了,但激活操作提供程序时生成的图标没有更改。请确保设置了正确的工具栏
setSupportActionBar(yourToolBar)看看这个:
<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar_equipment"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    app:title="@string/equipments"
    app:titleTextColor="@color/white"
    android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    app:collapseIcon="@drawable/ic_chevron_left_white_48dp" />