在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 (将#修改为@)