【发布时间】:2026-02-23 17:35:01
【问题描述】:
我是 Android 开发的新手,也是一名设计师兼前端人员。
如何避免每次添加属性时都必须输入android:?
在其他文本编辑器 (TextMate) 中,我可以通过键入已知触发器和 tab 来自动完成单词来触发 sn-ps。 Eclipse 有类似的东西吗?
【问题讨论】:
标签: android eclipse autocomplete attributes
我是 Android 开发的新手,也是一名设计师兼前端人员。
如何避免每次添加属性时都必须输入android:?
在其他文本编辑器 (TextMate) 中,我可以通过键入已知触发器和 tab 来自动完成单词来触发 sn-ps。 Eclipse 有类似的东西吗?
【问题讨论】:
标签: android eclipse autocomplete attributes
只需开始输入关键字的第二部分(android: 之后的内容,然后按 Ctrl + Space,Eclipse 将为您插入所需的关键字,前缀为android:.
【讨论】:
首先使用 Ctrl+Space。然后开始输入任何内容。使用箭头键浏览列表,然后按 Enter 选择一个。
:-)
【讨论】:
您可以通过在新行的开头按 Ctrl+Space 来调出自动完成对话框。
此外,我想添加一条说明,说明为什么您需要输入 android:(以及如何将其更改为您想要的任何内容)。
如果你查看布局文件中的第一个元素,会出现这样的一行:
xmlns:android="http://schemas.android.com/apk/res/android"
如果您在此处更改单词 android,那么这将是您需要输入的前缀 - 所以如果您改为设置
xmlns:a="http://schemas.android.com/apk/res/android"
那么你所有的属性只需要在前面加上a:,例如在这个例子中:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
a:layout_width="fill_parent"
a:layout_height="fill_parent"
a:orientation="vertical" >
<TextView
a:layout_width="fill_parent"
a:layout_height="wrap_content"
a:text="@string/hello" />
</LinearLayout>
【讨论】: