在日志中查看消息:"app:theme is deprecated"?

spi*_*ce7 48 android android-appcompat android-toolbar

自从升级到最新的appcompat库以来,我在ViewUtils的日志中看到了一条消息.

app:theme is now deprecated. Please move to using android:theme instead.

parent="Theme.AppCompat.Light.NoActionBar"用作我的主题父母.

ade*_*dek 70

替换app:themeandroid:theme但您可以在不使用时出现这种情况app:theme.检查您的布局,尤其是工具栏布局.在我的情况下,我没有app:theme在我的布局文件中.然后看看我的情况:

<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:styled="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar_actionbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    android:minHeight="?attr/actionBarSize"
    styled:popupTheme="@style/ToolbarDarkPopup"
    styled:theme="@style/ActionBarThemeOverlay" />
Run Code Online (Sandbox Code Playgroud)

我已将此布局更改为:

<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/toolbar_actionbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    android:minHeight="?attr/actionBarSize"
    android:theme="@style/ActionBarThemeOverlay" />
Run Code Online (Sandbox Code Playgroud)

现在我没有看到警告.

看看这里:https: //chris.banes.me/2015/04/22/support-libraries-v22-1-0/

Chris Banes的精彩解释


Gre*_*nis 18

我有另一个案例,当我Toolbar在styles.xml中设置样式时发生这种情况.它看起来像这样:

<style name="AppActionBar" parent="Widget.AppCompat.ActionBar">
    <item name="android:background">@color/ng_blue</item>
    <item name="theme">@style/ThemeOverlay.AppActionBar</item>
    <item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
</style>
Run Code Online (Sandbox Code Playgroud)

更改name="theme"name="android:theme"它解决了这一问题.


Gab*_*tti 15

检查你的布局.

您正在使用Toolbar已定义的位置app:theme.

现在支持22.1 app:theme已被弃用.你应该用android:theme

点击此处了解更多信息.