【发布时间】:2011-03-07 19:03:27
【问题描述】:
是否可以通过 ViewStub 将自定义属性传递给目标布局的根元素?像这样:
<ViewStub
android:layout="@layout/custom_view"
app:customAttr="12345"
/>
custom_view.xml 在哪里:
<blah.CustomView ...>
...
</blah.CustomView>
当我尝试这样做时,CustomView.java 没有在 AttributeSet 中获得“app:customAttr”。
当我直接使用CustomView时,没有ViewStub
<blah.Custom app:customAttr="12345"/>
属性进入 AttributeSet ok。
但它不再懒惰了。
有什么解决办法吗?
谢谢, 尤里。
【问题讨论】:
标签: android custom-attributes viewstub