您的位置:首页 > 移动开发 > Android开发

Android Studio模板

2017-02-09 16:20 267 查看
Live Templates系列:

一、layout模板

tv:
<TextView
android:id="@+id/tv_exp_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:textColor="@color/bbs_main_yellow"
android:textSize="14sp"
android:text="颜值" />
--------------------------------------------
image:
<ImageView
android:id="@+id/xxx"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="@drawable/xxx" />

二、注释模板

1、${USER}
找到androidstudio的安装目录/bin下面的idea.exe.vmoptions 和idea64.exe.vmoptions这两个文件,在里面添加
-Duser.name=bruce.zhang

2、快捷键
类注释没有快捷键,方法注释有(Ctrl+Alt+1)。类注释需要在Live Templates设置。http://blog.csdn.net/sun_promise/article/details/45642319

3、方法默认修改
方法注释如果通过Live Templates修改的话,不灵活,没法获取生成参数信息。可以通过javadoc插件实现。

三、java代码片段

singleton:

private $CLASS$() {}

private static class SingletonLoader {
private static final $CLASS$ INSTANCE = new $CLASS$();
}

public static $CLASS$ getInstance() {
return SingletonLoader.INSTANCE;
}
--------------------------------------------
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: