我有一个自定义视图,我只是希望访问 xml 布局值layout_height
.
我目前正在获取该信息并将其存储在 onMeasure 期间,但这仅在首次绘制视图时发生。我的视图是 XY 图,它需要尽早知道其高度,以便可以开始执行计算。
该视图位于 viewFlipper 布局的第四页上,因此用户可能暂时不会翻转到它,但是当他们翻转到它时,我希望视图已经包含数据,这要求我有高度进行计算。
谢谢!!!
那行得通:)...你需要将“android”更改为“http://schemas.android.com/apk/res/android http://schemas.android.com/apk/res/android"
public CustomView(final Context context, AttributeSet attrs) {
super(context, attrs);
String height = attrs.getAttributeValue("http://schemas.android.com/apk/res/android", "layout_height");
//further logic of your choice..
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)