简体   繁体   English

错误:使用.png时文件名必须以.xml或.png结尾

[英]Error: The file name must end with .xml or .png when using .png

I'm new, so maybe I'm doing something completely wrong, but I keep receiving this error when, to my knowledge, I'm using .png files (in the drawable folder I see my two pictures with a .png at the end). 我是新手,所以也许我正在做某些完全错误的事情,但是,据我所知,当我使用.png文件时(在可绘制文件夹中,我看到两张带有.png的图片时,我仍然收到此错误)。结束)。

Here's the error I'm getting: 这是我得到的错误:

C:\\Users\\student\\AndroidStudioProjects\\MainScreen\\app\\src\\main\\res\\drawable\\water_cup_toggle: Error: The file name must end with .xml or .png

and here's the code in water_cup_toggle 这是water_cup_toggle的代码

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:checked="false"
        android:drawable="@drawable/emptywatercupresize2" />
    <item
        android:checked="true"
        android:drawable="@drawable/fullwatercupresize2" />
</selector>

I've looked at other similar questions and it seems that they were from people who weren't using .xml or .png files, but nothing for something else that may have gone wrong. 我看过其他类似的问题,似乎它们来自未使用.xml或.png文件的人,但对于其他可能出错的问题,则毫无问题。 Has anyone else encountered this problem or can think of a fix? 其他人是否遇到过此问题,或者可以考虑解决问题?

Welcome to StackOverflow :-) 欢迎来到StackOverflow :-)

It looks like you forgot to give an extension to your file. 您好像忘记了给文件扩展名。

Rename water_cup_toggle to water_cup_toggle.xml and you'll be set! water_cup_toggle重命名为water_cup_toggle.xml ,您将被设置!

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

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