我正在使用新的Android appcompat工具栏。我需要为汉堡图标和后退箭头图标设置相同的自定义颜色。使用drawerArrowStyle允许我更改汉堡图标而不是箭头。问题只出现在Lollipop设备上,任何前棒棒糖都可以。
以下是代码:
工具栏:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="@color/my_primary"
local:theme="@style/My.Toolbar"
local:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
Style.xml:
<style name="Theme.Base" parent="Theme.AppCompat.Light">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">@color/my_primary</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">@color/black</item>
</style>
<style name="My.Theme" parent="Theme.Base">
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
</style>
<style name="My.Toolbar" parent="Theme.AppCompat.NoActionBar">
<!-- color of the title text in the Toolbar, in the Theme.AppCompat theme: -->
<item name="android:textColorPrimary">@color/my_actionbartext</item>
<!-- necessary to support older Android versions.-->
<item name="actionMenuTextColor">@color/my_actionbartext</item>
<item name="android:textColorSecondary">@color/my_actionbartext</item>
</style>
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="color">@color/my_actionbartext</item>
</style>
我尝试使用here的解决方案,但它没有用。有人有什么想法吗?
答案 0 :(得分:2)
只需在您的活动/片段中执行此操作:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
getSupportActionBar().setHomeAsUpIndicator(getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha, null));
else
getSupportActionBar().setHomeAsUpIndicator(getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
答案 1 :(得分:1)
答案 2 :(得分:1)
升级到23.2.0支持库
后,我也无法更新后退箭头按钮<ion-segment [(ngModel)]="subsActiveDay">
<ion-segment-button value="2016-03-01T00:00:00.000Z">
1
</ion-segment-button>
<ion-segment-button value="2016-03-02T00:00:00.000Z">
2
</ion-segment-button>
</ion-segment>
{{subsActiveDay}}
答案 3 :(得分:0)
它是actionMenuTextColor的颜色。将此行添加到您的主题中。
<item name="actionMenuTextColor">your color</item>