溢出工具栏图标(三个点)不会改变颜色(API 15)
Overflow Toolbar Icon (Three dots) doens't change color (API 15)
我想把图标染成白色。
这是工具栏:
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:theme="@style/Toolbar"
app:popupTheme="@style/PopupToolbar"/>
以及样式:
<style name="MyTheme" parent="carbon_Theme.Light.NoActionBar">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primaryDark</item>
<item name="colorAccent">@color/accent</item>
<item name="android:colorBackground">@color/background</item>
<item name="android:textColor">@color/texto</item>
<item name="android:textColorPrimary">@color/white</item>
</style>
<style name="Toolbar" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="android:background">@color/primary</item>
<item name="android:textColorPrimary">@color/white</item>
</style>
事实是,所有属性都有效,除了 #%&@! "three dots" 颜色。在 API 23
设备中,图标为白色。该问题只发生在 API 15
设备上,它是黑色的。为什么。
P.S。我也尝试过直接应用主题:
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
但还是会发生。 API 23
白色图标,API 15
黑色图标。
您可能 运行 遇到 Gradle 自动生成可绘制对象的问题。我们遇到了类似的问题,但导航工具栏中有向上导航箭头。
对于 Gradle 2.0:
// Gradle Plugin 2.0+
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
对于Gradle 1.5
// Gradle Plugin 1.5
android {
defaultConfig {
generatedDensities = []
}
// This is handled for you by the 2.0+ Gradle Plugin
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
完整文章在这里:http://android-developers.blogspot.com/2016/02/android-support-library-232.html
即使您没有专门使用支持库中的新 Vector Drawable,这仍然会影响我们的项目。
已接受的答案对我不起作用。对我有用的是使用以下方法在布局文件中设置主题:
<android.support.v7.widget.Toolbar
:
android:theme="@style/ActionBarTheme" />
并在 styles.xml
<style name="ActionBarTheme" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
:
</style>
我想把图标染成白色。
这是工具栏:
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:theme="@style/Toolbar"
app:popupTheme="@style/PopupToolbar"/>
以及样式:
<style name="MyTheme" parent="carbon_Theme.Light.NoActionBar">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primaryDark</item>
<item name="colorAccent">@color/accent</item>
<item name="android:colorBackground">@color/background</item>
<item name="android:textColor">@color/texto</item>
<item name="android:textColorPrimary">@color/white</item>
</style>
<style name="Toolbar" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="android:background">@color/primary</item>
<item name="android:textColorPrimary">@color/white</item>
</style>
事实是,所有属性都有效,除了 #%&@! "three dots" 颜色。在 API 23
设备中,图标为白色。该问题只发生在 API 15
设备上,它是黑色的。为什么。
P.S。我也尝试过直接应用主题:
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
但还是会发生。 API 23
白色图标,API 15
黑色图标。
您可能 运行 遇到 Gradle 自动生成可绘制对象的问题。我们遇到了类似的问题,但导航工具栏中有向上导航箭头。
对于 Gradle 2.0:
// Gradle Plugin 2.0+
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
对于Gradle 1.5
// Gradle Plugin 1.5
android {
defaultConfig {
generatedDensities = []
}
// This is handled for you by the 2.0+ Gradle Plugin
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
完整文章在这里:http://android-developers.blogspot.com/2016/02/android-support-library-232.html
即使您没有专门使用支持库中的新 Vector Drawable,这仍然会影响我们的项目。
已接受的答案对我不起作用。对我有用的是使用以下方法在布局文件中设置主题:
<android.support.v7.widget.Toolbar
:
android:theme="@style/ActionBarTheme" />
并在 styles.xml
<style name="ActionBarTheme" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
:
</style>