<com.test.www.BrushPreview android:id="@+id/brushview"
android:layout_width="100dip" android:layout_height="100dip"
android:layout_gravity="center" />
这不是:
<View class="com.test.www.BrushPreview" android:id="@+id/brushview"
android:layout_width="100dip" android:layout_height="100dip"
android:layout_gravity="center" />
遵循文档http://developer.android.com/guide/topics/ui/custom-components.html#modifying它应该是双向的!我究竟做错了什么?
编辑:
小写视图似乎有效!我想我已经尝试过了...谢谢!
此外,在视图类中使用这个构造函数非常重要:
public BrushPreview(Context context, AttributeSet attrs)
否则它不会被调用。
你应该使用小写view
在您的自定义布局的 xml 中:
<view class="com.test.www.BrushPreview" android:id="@+id/brushview"
android:layout_width="100dip" android:layout_height="100dip"
android:layout_gravity="center" />
(根据你的链接也),它应该可以工作。
否则它会尝试创建一个android.view.View
实例。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)