I’ve been encountering some very odd problems with Android Studio today.
When I open an XML layout file, it opens as a plain text for some reason. It even says that I have a typo for constraintLayout
and tells me to change it to constraint's layout
.
There’s no design view choice in sight.
I tried adding elements by hand in the XML file but, when I type in Text
usually the TextView property should appear for me to choose. However, that doesn’t show up lol.
I tried invalidating caches, rebuilding my project, cleaning my project, restarting my laptop, and this method: Android Studio not identifying xml file as layout file but they all don’t work for some reason.
Usually my layout files should have a small icon thing in the file structure thing but that also doesn’t show up.
Thanks so much.
Edit: here’s what it looks like in my XML file
I also tried just adding things to my XML by hand and running it on my device. The thing does run, and my textView shows up on my screen, but when I try to use findViewById
to find it in my activity file, it can’t find the id.
2
Answers
Right click on
activity_login.xml
file from Project/android view structure and selectMark as XML
. Somehow this file marked as text file from your IDE.can you check that
activity_login.xml
is in the correct directoryres/layout
? I found the same issue, I resolved the issue by clearing caches inAndroid Studio
. Follow Steps to Clear CachesGo to
File > menu > Invalidate Caches > select option invalidate
and restartAndroid Studio
.