Android Studio xml layout files not recognized as layout file

Issue

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
enter image description here

What the icon looks like:
enter image description here

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.

Solution

Right click on activity_login.xml file from Project/android view structure and select Mark as XML . Somehow this file marked as text file from your IDE.

Answered By – Zahid Islam

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published