微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在abc_list_menu_item_icon中,如果故意,则使用tools:override =“ true”,否则请选择其他名称 [PrivateResource]

如何解决在abc_list_menu_item_icon中,如果故意,则使用tools:override =“ true”,否则请选择其他名称 [PrivateResource]

我正在努力将图标添加到溢出菜单 但是发现它在RTL中是无效的,更干净的解决方案是覆盖abc_list_menu_item_icon私有资源并调整图标边距 在RTL和LTR中效果很好 但我遇到了皮棉错误

错误:覆盖了@ layout / abc_list_menu_item_icon,该标记为 在com.google.android.material:material中是私有的。如果故意,请使用 tools:override =“ true”,否则请选择其他名称。 [PrivateResource]

即使在资源文件中使用tools:override =“ true”之后,我仍然收到此错误

这是我添加到项目中的资源文件内容

 <?xml version="1.0" encoding="utf-8"?><!-- copyright (C) 2007 The Android Open Source Project

     Licensed under the Apache License,Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing,software
     distributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<!-- Added this file to fix the overflow menu icon padding issues in RTL -->
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/icon"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical"
    android:layout_marginStart="16dip"
    android:layout_marginTop="8dip"
    android:layout_marginEnd="0dip"
    android:layout_marginBottom="8dip"
    android:duplicateParentState="true"
    android:scaleType="centerInside"
    tools:ignore="contentDescription"
    tools:override="true" />

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。