cot*_*aws 20 xml android attr android-xml
我知道如何为视图创建自定义属性,例如:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="SomeViewsCustomAttrs">
<attr name="someAttr" format="dimension" />
<attr name="anotherAttr" format="boolean" />
</declare-styleable>
</resources>
Run Code Online (Sandbox Code Playgroud)
我想知道是否有办法向这些自定义attrs添加文档.在XML编辑器中编辑布局时,您可以获得描述attrs内容的工具提示.例如,如果您键入android:layout_width=它,它将为您提供以下信息,"指定视图的基本宽度.[dimension,enum]"
有没有办法为你自己的attrs提供?
谢谢
为每个元素添加 XML 注释:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="SomeViewsCustomAttrs">
<!-- Default highlight color for items that are pressed. -->
<attr name="colorPressedHighlight" format="color" />
<!-- Default highlight color for items that are long-pressed. -->
<attr name="colorLongPressedHighlight" format="color" />
</declare-styleable>
</resources>
Run Code Online (Sandbox Code Playgroud)
并且在您的视图的 Java 源文件中的 Java Doc 中,链接到这样的属性(来自TextView 的示例):
* See {@link android.R.styleable#TextView TextView Attributes}, {@link android.R.styleable#View View Attributes}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1018 次 |
| 最近记录: |