【问题标题】:Different colours for icons in the ActionBarActionBar 中图标的不同颜色
【发布时间】:2016-03-12 13:15:07
【问题描述】:

根据设备的 API 级别,我的应用操作栏中的图标有不同的颜色。我希望它们在所有设备上看起来都一样。

这就是它在 API 23 中的样子,这也是我希望它在所有设备中的样子:

这就是它在旧版本中的样子:

我有以下styles.xml:

values/styles.xml

<style name="MyMaterialTheme" parent="MyMaterialTheme.Base">

</style>

<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

v21/styles.xml

<style name="MyMaterialTheme" parent="MyMaterialTheme.Base">
    <item name="android:windowContentTransitions">true</item>
    <item name="android:windowAllowEnterTransitionOverlap">true</item>
    <item name="android:windowAllowReturnTransitionOverlap">true</item>
    <item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
    <item name="android:windowSharedElementExitTransition">@android:transition/move</item>
</style>

这是actionBar的布局:

...
<android.support.v7.widget.Toolbar
        android:id="@+id/my_toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        android:elevation="4dp"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
...

这是我的 Manifest.xml 的一部分

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:name="com.martinez.mario.rutapp.base.RutappApplication"
        android:theme="@style/MyMaterialTheme" >

如何使箭头和溢出图标在所有设备中都显示为白色?

谢谢。

【问题讨论】:

  • 我刚刚意识到我的应用程序也是如此。 +1
  • 奇怪的是,我最近编写的一个应用程序在

标签: android android-layout android-actionbar


【解决方案1】:

您可能在 appcompat 支持库 23.2.0 中遇到了错误,更新到 23.2.1 或启用支持向量可绘制对象:

vectorDrawables.useSupportLibrary = true

Appcompat 在 23.2.0 中引入了矢量支持绘图的生成(如果启用),问题是 appcompat 本身利用了这一点并且也使用了它,但这需要启用矢量绘图生成。它自己对它的使用在 23.2.1 中再次恢复,因此不需要这样做。

【讨论】:

  • 那么矢量drawables现在固定了吗?我暂时用的是23.1.0
猜你喜欢
  • 2018-07-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-03-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多