移动到 Android 设计支持 v23 后,TabLayout 样式无法解析 @dimen/tab_max_width

TabLayout style cannot resolve @dimen/tab_max_width after moving to Android Design Support v23

迁移到 Android 设计支持 v23.0.0 后,Android Studio 无法构建一个使用 Android 设计支持 v22.2.1 构建良好的项目:

找不到与给定名称匹配的资源(在 'tabMaxWidth' 处,值为“@dimen/tab_max_width”)。

怎么回事?

简而言之:您可能只需要在这些值前添加 'design_'。

很高兴你问,帅哥。 v23.0.0 改变了一堆值,这里是 v22.2.1 的旧值:

<color name="error_color">#FFDD2C00</color>
<color name="fab_stroke_end_inner_color">#0A000000</color>
<color name="fab_stroke_end_outer_color">#0F000000</color>
<color name="fab_stroke_top_inner_color">#1AFFFFFF</color>
<color name="fab_stroke_top_outer_color">#2EFFFFFF</color>
<color name="shadow_end_color">@android:color/transparent</color>
<color name="shadow_mid_color">#14000000</color>
<color name="shadow_start_color">#44000000</color>
<color name="snackbar_background_color">#323232</color>
<dimen name="appbar_elevation">4dp</dimen>
<dimen name="fab_border_width">0.5dp</dimen>
<dimen name="fab_content_size">24dp</dimen>
<dimen name="fab_elevation">8dp</dimen>
<dimen name="fab_size_mini">40dp</dimen>
<dimen name="fab_size_normal">56dp</dimen>
<dimen name="fab_translation_z_pressed">6dp</dimen>
<dimen name="navigation_elevation">12dp</dimen>
<dimen name="navigation_icon_padding">32dp</dimen>
<dimen name="navigation_icon_size">24dp</dimen>
<dimen name="navigation_max_width">320dp</dimen>
<dimen name="navigation_padding_bottom">8dp</dimen>
<dimen name="navigation_padding_top_default">0dp</dimen>
<dimen name="navigation_separator_vertical_padding">8dp</dimen>
<dimen name="snackbar_action_inline_max_width">128dp</dimen>
<dimen name="snackbar_background_corner_radius">0dp</dimen>
<dimen name="snackbar_elevation">2dp</dimen>
<dimen name="snackbar_extra_spacing_horizontal">0dp</dimen>
<dimen name="snackbar_max_width">-1px</dimen>
<dimen name="snackbar_min_width">-1px</dimen>
<dimen name="snackbar_padding_horizontal">12dp</dimen>
<dimen name="snackbar_padding_vertical">14dp</dimen>
<dimen name="snackbar_padding_vertical_2lines">24dp</dimen>
<dimen name="snackbar_text_size">14sp</dimen>
<dimen name="tab_max_width">264dp</dimen>
<dimen name="tab_min_width">72dp</dimen>
<integer name="snackbar_text_max_lines">2</integer>

现在是 v23.0.0 的新版本:

<color name="design_fab_shadow_end_color">@android:color/transparent</color>
<color name="design_fab_shadow_mid_color">#14000000</color>
<color name="design_fab_shadow_start_color">#44000000</color>
<color name="design_fab_stroke_end_inner_color">#0A000000</color>
<color name="design_fab_stroke_end_outer_color">#0F000000</color>
<color name="design_fab_stroke_top_inner_color">#1AFFFFFF</color>
<color name="design_fab_stroke_top_outer_color">#2EFFFFFF</color>
<color name="design_snackbar_background_color">#323232</color>
<color name="design_textinput_error_color">#FFDD2C00</color>
<dimen name="design_appbar_elevation">4dp</dimen>
<dimen name="design_fab_border_width">0.5dp</dimen>
<dimen name="design_fab_content_size">24dp</dimen>
<dimen name="design_fab_elevation">6dp</dimen>
<dimen name="design_fab_size_mini">40dp</dimen>
<dimen name="design_fab_size_normal">56dp</dimen>
<dimen name="design_fab_translation_z_pressed">6dp</dimen>
<dimen name="design_navigation_elevation">16dp</dimen>
<dimen name="design_navigation_icon_padding">32dp</dimen>
<dimen name="design_navigation_icon_size">24dp</dimen>
<dimen name="design_navigation_max_width">320dp</dimen>
<dimen name="design_navigation_padding_bottom">8dp</dimen>
<dimen name="design_navigation_padding_top_default">0dp</dimen>
<dimen name="design_navigation_separator_vertical_padding">8dp</dimen>
<dimen name="design_snackbar_action_inline_max_width">128dp</dimen>
<dimen name="design_snackbar_background_corner_radius">0dp</dimen>
<dimen name="design_snackbar_elevation">6dp</dimen>
<dimen name="design_snackbar_extra_spacing_horizontal">0dp</dimen>
<dimen name="design_snackbar_max_width">-1px</dimen>
<dimen name="design_snackbar_min_width">-1px</dimen>
<dimen name="design_snackbar_padding_horizontal">12dp</dimen>
<dimen name="design_snackbar_padding_vertical">14dp</dimen>
<dimen name="design_snackbar_padding_vertical_2lines">24dp</dimen>
<dimen name="design_snackbar_text_size">14sp</dimen>
<dimen name="design_tab_max_width">264dp</dimen>
<dimen name="design_tab_min_width">72dp</dimen>
<integer name="design_snackbar_text_max_lines">2</integer>