简体   繁体   English

Android:覆盖布局中的资源

[英]Android: override Resource in layout

Sometimes I see a warning like this:有时我会看到这样的警告:

在此处输入图像描述

What happen if I override or not the layout Resource?如果我覆盖或不覆盖布局资源会发生什么?

If you override the layout resource, a new copy of it is created with configuration qualifiers.如果您覆盖布局资源,则会使用配置限定符创建它的新副本。 In this case, layout-v26 .在这种情况下, layout-v26 This version of the resource is used on API level 26 and above while the qualifier-free version in layout is the default.此版本的资源用于 API 级别 26 及以上,而layout中的无限定符版本是默认设置。

For issues like this you probably don't want to do that as then you have one more version of the layout to maintain.对于这样的问题,您可能不想这样做,因为您还有一个版本的布局需要维护。

Unknown XML attributes are ignored at runtime, so the problem is only that the attribute does nothing on pre-v26 runtimes.未知的 XML 属性在运行时被忽略,所以问题只是该属性在 v26 之前的运行时中没有任何作用。 If that's fine, then you can just ignore the warning with tools:ignore="UnusedAttribute" .如果没问题,那么您可以使用tools:ignore="UnusedAttribute"警告。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM