Android Studio自定义模板(1),android屏幕适配五种方式

本文介绍了如何在Android Studio中自定义模板,详细解析了参数配置,如activityClass、layoutName和parentActivityClass等,并探讨了屏幕适配的五种常见方法。同时,展示了template_welcome_activity.png作为模板的预览。通过template的配置,包括merge、instantiate等指令,实现代码和资源的合并与生成。
摘要由CSDN通过智能技术生成

<parameter

id=“activityClass”

name=“Activity Name”

type=“string”

constraints=“class|unique|nonempty”

default=“WelcomeActivity”

help=“The name of the activity class to create” />

<parameter

id=“layoutName”

name=“Layout Name”

type=“string”

constraints=“layout|unique|nonempty”

suggest="${activityToLayout(activityClass)}"

default=“activity_welcome”

help=“The name of the layout to create for the activity” />

<parameter

id=“parentActivityClass”

name=“Hierarchical Parent”

type=“string”

constraints=“activity|exists|empty”

default=""

help=“The hierarchical parent activity, used to provide a default implementation for the ‘Up’ button” />

<parameter

id=“packageName”

name=“Package name”

type=“string”

constraints=“package”

default=“com.mycompany.myapp” />

template_welcome_activity.png

这里写图片描述

这里的配置和名称都是由template中进行配置的

thumb表示as显示的图片

注意:<parameter

id=“parentActivityClass”

name=“Hierarchical Parent”

type=“string”

constraints=“activity|exists|empty”

default=""

help=“The hierarchical parent activity, used to provide a default implementation for the ‘Up’ button” />

不能删除,否则as创建时会出错,其他的配置这里已经删除,

如果需要,可以去LoginActivity中copy

id :唯一标识,最终会通过它获取字符串 是否选中等等

name:界面上的左边的提示语

type : 输入值类型 可以是string int boolean 等等

constraints:填写值的约束 如文件名不能重复等等

suggest:建议值,比如填写ActivityName的时候,会给出一个布局文件的建议值。

default:默认值

help:显示的帮助提升语

2、globals.xml.ftl

一般不用动

3、recipe.xml.ftl

<?xml version="1.0"?>

<#if appCompat && !(hasDependency(‘com.android.support:a

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值