我已经创建了一个带有属性的自定义 View 。有没有办法在 Android studio 中将这些属性与 android 工具一起使用?
例如:
<MyOwnCoolView
android:layout_width="96dp"
android:layout_height="96dp"
android:padding="3dp"
tools:dividerAngle="2"/>
attr 文件在哪里:
<resources>
<declare-styleable name="MyOwnCoolView">
<attr name="dividerAngle" format="float"/>
</declare-styleable>
最佳答案
我的意见是你不能。
有一个官方的,虽然非常旧,页面here引用:
Designtime attributes can only be used for framework resources, not custom attributes at this point.
关于Android XML 有没有办法将工具命名空间与自定义属性一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33370878/