添加JS和CSS支持到Android Studio项目 [英] Add JS and CSS support to Android Studio project

查看:6006
本文介绍了添加JS和CSS支持到Android Studio项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚安装了新的Andr​​oid Studio和我正在寻找一种方法,能够得到支持CSS和JS(自动完成,突出了不正确的用法),我会在PHPStorm也WebStorm,既有的IntelliJ产品。

I just installed the new Android Studio and I'm looking for a way to be able to get support for CSS and JS (autocomplete, highlighting for incorrect usages) as i would in PHPStorm and also WebStorm, both intelliJ products.

我用Google搜索,甚至把它添加到文件类型,但还是老样子,他们只是显示为纯文本文件。

I have googled and even added it to 'File Types', but stil they just display as plain text files.

推荐答案

您可以得到语法高亮pretty的方便。

You can get syntax highlighting pretty easy.

在文件>设置>文件类型,创建一个JavaScript文件类型,并添加* .js文件的注册模式。您将需要添加的所有关键字。

In File > Settings > Files Types, create a Javascript file type and add *.js to the registered patterns. You will need to add all the keywords.

另外,您可以直接编辑XML文件。在Ubuntu的,存储在/家庭/用户名/ AndroidStudio preVIEW /配置/文件类型,而我看起来是这样的:

Alternatively you can edit the XML file directly. In Ubuntu it is stored at /home/"User Name"/.AndroidStudioPreview/config/filetypes, and mine looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<filetype binary="false" default_extension="" description="Javascript" name="Javascript">
  <highlighting>
    <options>
      <option name="LINE_COMMENT" value="//" />
      <option name="COMMENT_START" value="/*" />
      <option name="COMMENT_END" value="*/" />
      <option name="HEX_PREFIX" value="" />
      <option name="NUM_POSTFIXES" value="" />
      <option name="HAS_BRACES" value="true" />
      <option name="HAS_BRACKETS" value="true" />
      <option name="HAS_PARENS" value="true" />
      <option name="HAS_STRING_ESCAPES" value="true" />
    </options>
    <keywords keywords="break;case;catch;continue;debugger;default;delete;do;else;finally;for;function;if;in;instanceof;new;return;switch;this;throw;try;typeof;var;void;while;with" ignore_case="false" />
  </highlighting>
  <extensionMap>
    <mapping ext="js" />
  </extensionMap>
</filetype>

至于自动完成,你可能想看看文件守望,但我的避风港'吨琢磨出来呢。但我认为,如果你有PHPStorm和WebStorm你已经拥有你需要的IntelliJ插件。你可以添加自定义的插件。也许尝试加入免费IDEA插件WebStorm ...

As for autocompletion you may want to look into File Watcher, but I haven't figured it out yet. But I think if you have PHPStorm and WebStorm you already have the plugins you need for IntelliJ. And you can add custom plugins. Maybe try adding the free IDEA plugins to WebStorm ...

修改:在最新的Andr​​oid工作室(1.0)在Windows上,这些XMLS的位置如下:

EDIT: In the latest Android Studio (1.0) on Windows, the location of these XMLs is the following:

.AndroidStudio \设置\选项\ filetypes.xml

<?xml version="1.0" encoding="UTF-8"?>
<application>
  <component name="FileTypeManager" version="11">
    <ignoreFiles list="CVS;SCCS;RCS;rcs;.DS_Store;.svn;.pyc;.pyo;*.pyc;*.pyo;.git;*.hprof;_svn;.hg;*.lib;*~;__pycache__;.bundle;*.rbc;" />
    <extensionMap>
      <mapping ext="js" type="Javascript" />
    </extensionMap>
  </component>
</application>

.AndroidStudio \设置\文件类型\ Javascript.xml

<?xml version="1.0" encoding="UTF-8"?>
<filetype binary="false" default_extension="" description="Javascript Files" name="Javascript Files">
  <highlighting>
    <options>
      <option name="LINE_COMMENT" value="//" />
      <option name="COMMENT_START" value="/*" />
      <option name="COMMENT_END" value="*/" />
      <option name="HEX_PREFIX" value="" />
      <option name="NUM_POSTFIXES" value="" />
      <option name="HAS_BRACES" value="true" />
      <option name="HAS_BRACKETS" value="true" />
      <option name="HAS_PARENS" value="true" />
      <option name="HAS_STRING_ESCAPES" value="true" />
    </options>
    <keywords keywords="break;case;catch;continue;debugger;default;delete;do;else;finally;for;function;if;in;instanceof;new;return;switch;this;throw;try;typeof;var;void;while;with" ignore_case="false" />
  </highlighting>
  <extensionMap>
    <mapping ext="js" />
  </extensionMap>
</filetype>

这篇关于添加JS和CSS支持到Android Studio项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆