android-studioandroid-jetpack-composeandroid-jetpack-compose-preview

Android Studio always opens up Compose Preview pane no matter what kind of Kotlin file gets created


Recently, I stumbled upon what seems to be a strange glitch in Android Studio. No matter what kind of Kotlin file I create (object, interface, class—anything), the IDE always opens it as if it contains a Jetpack Compose function with previews. Most of the time, I have to manually switch back to the "Code" pane, since I create Fragments, ViewModels, and UseCases far more often than Composables. This ends up wasting time with each new file.

Is there a way to fix this through Studio’s configuration settings? I believe there should be some setting which I changed without even noticing it, because I couldn't find anything about such behavior on web, so most likely this is not an issue experienced by many.


Solution

  • You can toggle this in Settings | Editor | UI Tools:

    Make sure the setting for Kotlin is set to Code. You may want to tick the checkbox Show split mode if file contains preview annotation to automatically enable the split mode instead when the file actually contains previews.