123

I'm using IntelliJ Android-Studio 0.8.2 and i'd like to know if it's possible to open the code by default when editing XML files?

Opening multiple files always shows Design tab, while opening single files, though, it sometimes opens them in Text tab but sometimes not.

Is there any way to set the default tab to Text ? It's pretty annoying as I rarely use the Design tab. Here's a screenshot of what I'm talking about:

Design & Text Tabs

1
  • 3
    i had this tool bar vanished. any idea how to show it again? Commented Aug 3, 2017 at 12:49

12 Answers 12

57

Here is the screen shot of the latest version

Look at the top right corner of the image

Sign up to request clarification or add additional context in comments.

3 Comments

Just what I was looking for!
Yes, that is answer I needed. Kudos.
I wouldn't have known that those icons are part of the editor view....
44

Newer (I guess 2.x+) versions of Android Studio have this option in the main settings:

Open the settings with one of the following actions:

  • Press Ctrl+Alt+S.
  • On the main menu, choose File | Settings for Windows and Linux or IntelliJ IDEA | Preferences for OS X
  • Press Ctrl+Shift+A, type settings and press Enter.

Then navigate to the following sub-menu:

Editor -> Layout Editor -> "Prefer XML editor"

Screenshot of the Preferences

3 Comments

Android Studio -> Preferences -> Design Tools -> Default Editor Mode: Set all to 'Code'
@karlingen I don't see "Preferences" anywhere. I have "Design Tools" under File -> Settings.
@TheincredibleJan Yes, you are on Windows and I'm on a Mac :)
38

This has been added in the newest release of Android Studio (0.8.12).

default to xml editor

Other features of the new release can be found here.

2 Comments

It took me a minute to find this menu. It's accessed by the Options (gear) menu in the design view.
Newer versions seem to have this in the main settings.
37

UPDATE 2021

Using Android Studio Artic Fox 2020.3.1 it's Design Tools in Settings Menu (CtrlAltS) instead of Layout Editor:

enter image description here

3 Comments

This answer should be bumped up!
Note it's called Android Design Tools in IntelliJ
They changed the name again... It's UI Tools now.
12

2023 New UI Update

In the new refreshed AS UI the selection to change with the editor open like the OP is on the top right of the open files tool bar. The defaults are under Design Tools in the settings view.

View switch for xml design and code

enter image description here

2 Comments

Note it's called Android Design Tools in IntelliJ
Now it's UI Tools
11

In case of Android Studio 4.0 use Split OR Code button to view it.

enter image description here

Comments

6

Since in the new update, the feature of viewing the code of XML has changed, there are some series of steps that are needed to be followed.

Step 1: Press Ctrl + Alt + S (Basically opening settings)

The screen visible to you after Step 1

Step 2:Click on the layout editor and choose the default Editor mode as you wish. In my case I want it to be in split mode (You will be able to see both code and its output at the same screen or window).

Step 3: Click on Apply and OK.

Apply and Ok output screen

Step 4: Close all the opened XML or the design files . Now after this step , if you open any other file present at your project, you would be realizing that the mode in which the file is opened is at the mode you chose at the Step 2 .

1 Comment

Thank you. I do not know why Google has gone so far to discourage using the text editor which is often the cleanest way to design layouts with clear logic and structure.
4

Found at: Settings -> Editor -> UI Tools -> Editor View Mode: Resource: Code

Android Studio XML as code setting:

Android Studio XML as code setting

Windows 10 and recent Android Studio version:

Android Studio Ladybug Feature Drop | 2024.2.2

Comments

3

Mac

Android Studio > Preferences > Editor > Layout Editor change to the view as per your desire.

Also you can switch between views Using Cmd + Shift + Left/Right Arrow

Comments

3

For Android Studio - giraffe, look at the top right corner of your work space. You should see: Code Split Design, with Design highlighted by default. Click on Code to switch to text mode.

Comments

2

In the new Android Studio 4.1 this option is somewhat changed to : enter image description here

To access this visit Android Studio -> Preference from the menu bar search for design and select layout editor and change the mode to your desired one.

Thanks

Comments

-2

The Android Designer editor always opens files in the "Design" mode by default. Once you have it open you can switch to "Text" mode and it will retain that setting for that file. However, there's no option to have it default to opening XML files in "Text" mode.

4 Comments

Though if you open multiple files it just goes ahead and opens it in design and resets that setting..
That stinks - I've not tried that particular use case. You might try filing a bug report or enhancement request with the Android tools team or JetBrains for this.
The feature request for this is at code.google.com/p/android/issues/detail?id=73299
This is no longer true, see above answers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.