Android-Studio 显示 XML 代码而不是设计

我正在使用 IntelliJ Android-Studio 0.8.2,我想知道是否有可能打开代码默认编辑 XML 文件?

打开多个文件时总是显示“设计”选项卡,而打开单个文件时,有时会在“文本”选项卡中打开它们,有时则不会。

有没有办法把默认选项卡设置为 短信?这很烦人,因为我很少使用“设计”选项卡。下面是我所说的截图:

Design & Text Tabs

先谢谢你。

46689 次浏览

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.

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.

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

Here is the screen shot of the latest version

Look at the top right corner of the image

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

enter image description here

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

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

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 .

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