IntelliJ IDEA 2017.2 Help

Creating Resources

Besides the standard way to create files and folders, you can create resource definitions right from the res node without having to place them in the corresponding folder. IntelliJ IDEA detects the type and the qualifier of the new resource and appoints the folder where the resource definition file will be saved. You can create separate resource definition files and entire folders.

In this topic:

Creating a resource folder

IntelliJ IDEA composes the name for the new resource folder from the resource type and the qualifiers you choose, and creates a folder with this name under the res folder. The name is built in compliance with the Android naming conventions.

  1. In the Project tool window, right-click the res node where all Android resource definitions are stored. Select New | Android resource directory from the context menu. The New Resource Directory dialog box opens.
  2. From the Resource Type drop-down list, select the type of resources to be stored in the new folder. The selected type is displayed in the Directory name field.
  3. Do one of the following:
    • If your application does not need to be compatible with various Android devices and, therefore, no multiple screens support is required, just click OK.
    • To provide alternative resources, specify the resource qualifiers that define a specific device configuration.
      • From the Available Qualifiers list, select the required qualifier, and click the icon_InsertReplace.gif button. The selected item is added to the Chosen qualifiers list. Depending on a particular qualifier, either specify its value manually, or choose the required value from the drop-down list next to Chosen qualifiers.
      • To remove a qualifier, select it in the Chosen qualifiers list and click the icon_InsertReplace2.gif button.

      IntelliJ IDEA appends all selected qualifiers to the resource type with the dash character as a separator. The resulting name is shown in the Directory name field.

IntelliJ IDEA generates the new folder with the compound name under the res node.

Creating a resource definition file in the relevant resource folder

  1. In the Project tool window, right-click the res node where all Android resource definitions are stored. Select New | Android resource file from the context menu. The New Resource File dialog box opens.
  2. Specify the name for the new resource definition file in the File name text box. Follow the Android naming guidelines
  3. From the Resource Type drop-down list, select the resource type. You can scroll through the list of resource types right from the File name text box by using the Up and Down keyboard keys.
  4. To enable coding assistance, in the Root element field, specify the http://schemas.android.com/apk/res/android schema as the value of the xmlns:android.
  5. Do one of the following:
    • If your application does not need to be compatible with various Android devices and, therefore, no multiple screens support is required, just click OK.
    • To provide alternative resources, specify the resource qualifiers that define a specific device configuration.
      • From the Available Qualifiers list, select the required qualifier, and click the icon_InsertReplace.gif button. The selected item is added to the Chosen qualifiers list. Depending on a particular qualifier, either specify its value manually, or choose the required value from the drop-down list next to Chosen qualifiers.
      • To remove a qualifier, select it in the Chosen qualifiers list and click the icon_InsertReplace2.gif button.

      IntelliJ IDEA appends all selected qualifiers to the resource type with the dash character as a separator. The resulting name is shown in the Directory name field.

  6. Click OK, when ready. IntelliJ IDEA composes the name of the resource folder where the new file is going to be saved. The name is built from the specified resource type and the qualifier in compliance with the Android naming conventions. If such folder exists already, IntelliJ IDEA saves the new file in it. If no such folder is found, IntelliJ IDEA creates it under the res node and saves the new resource definition file there.
Last modified: 29 November 2017

See Also