Android 安卓工作室。错误:文件名必须以.xml结尾
我正在尝试在我的应用程序的操作栏上添加图标,因此我在drawable文件夹中导入了一个图标(.png),但出现了一个错误,文件名必须以.xml结尾 以下是我的xml代码:Android 安卓工作室。错误:文件名必须以.xml结尾,android,xml,android-studio,Android,Xml,Android Studio,我正在尝试在我的应用程序的操作栏上添加图标,因此我在drawable文件夹中导入了一个图标(.png),但出现了一个错误,文件名必须以.xml结尾 以下是我的xml代码: <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-a
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity">
<item android:id="@+id/action_create_order"
android:title="@string/action_create_order"
android:icon="@drawable/ic_action_name"
android:orderInCategory="1"
app:showAsAction="always">
</item>
<item android:id="@+id/action_settings"
android:title="@string/action_settings"
android:orderInCategory="100"
app:showAsAction="never" />
</menu>
第一个项目(ic_action_name)出现错误。您需要在
绘图文件夹上使用向量
在可绘图/ic\u菜单\u camera.xml
上尝试以下示例:
ic\u菜单\u camera.xml
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12,12m-3.2,0a3.2,3.2 0,1 1,6.4 0a3.2,3.2 0,1 1,-6.4 0" />
<path
android:fillColor="#FF000000"
android:pathData="M9,2L7.17,4H4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2V6c0,-1.1 -0.9,-2 -2,-2h-3.17L15,2H9zm3,15c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5z" />
</vector>