skip to Main Content

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.

2

Answers


  1. 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.

    Login or Signup to reply.
  2. can you check that activity_login.xml is in the correct directory res/layout? I found the same issue, I resolved the issue by clearing caches in Android Studio. Follow Steps to Clear Caches
    Go to File > menu > Invalidate Caches > select option invalidate and restart Android Studio.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search