Android XML 有没有办法将工具命名空间与自定义属性一起使用?

标签 android android-layout android-view android-xml android-tools-namespace

我已经创建了一个带有属性的自定义 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/

相关文章:

android - 如何测试自定义 View 性能

android - 点击从 BroadcastReceiver 推送的通知时打开 Activity

android - 如何创建 "informative"首选项

android - 与 View 动画作斗争

Android addRulerelativeLayout.BELOW 无法正确渲染

安卓 : Draw Circle With Text Inside

android - 以编程方式在后台有 GL View 的软键盘上使用 EditText

android - @MainThread 注释没有错误

javascript - 如何获得用户偏好的单位?米或英里

android - 如何在我的 android 应用程序主屏幕中实现以下转换?