问题描述
我将 com.google.android.gms.oss-licenses-plugin
与 Google 的 play-services-oss-licenses
库一起使用。我的默认主题不包含操作栏,因此我使用操作栏 Theme.With.ActionBar
定义了另一个主题。
一切正常。我只是无法将操作栏的后退图标 ←
替换为关闭图标 ⨯
,尽管我尝试将其设置为 [android:]homeAsUpIndicator
和 [android:]collapseIcon
主题 Theme.With.ActionBar
和引用的 actionBarTheme
样式属性。
我怎样才能做到这一点?
<activity
android:name="com.google.android.gms.oss.licenses.OssLicensesMenuActivity"
android:exported="false"
android:label="@string/oss_license_title"
android:theme="@style/Theme.With.ActionBar">
<intent-filter>
<action android:name="ACTION_LICENSES" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<style name="Theme.With.ActionBar" parent="Theme.WithOut.ActionBar">
<item name="actionBarWidgetTheme">@null</item>
<item name="actionBarTheme">@style/ThemeOverlay.MaterialComponents.Dark.ActionBar</item>
<item name="listChoiceBackgroundindicator">@drawable/abc_list_selector_holo_dark</item>
<item name="windowActionBar">true</item>
<item name="windowActionModeOverlay">false</item>
<item name="windowNoTitle">false</item>
</style>
这个问题也可能与其他库有关。我的设备运行的是 Android 10。
解决方法
只需将此行添加到您的styles.xml
<item name="navigationIcon">@drawable/ic_back_arrow</item>