public class TestView extends View {
public TestView(Context context) {
super(context);
Log.d(“mDebug”, “TestView context”);
}
public TestView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
Log.d(“mDebug”, “TestView context,attrs,defStyle attrs=”+attrs.getAttributeValue(0));
}
public TestView(Context context, AttributeSet attrs) {
super(context, attrs);
Log.d(“mDebug”, “TestView context, attrs=”+attrs.getAttributeValue(0));
}
@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.onDraw(canvas);
Log.d(“mDebug”, “onDraw”);
}
@Override
protected void onFinishInflate() {
// TODO Auto-generated method stub
super.onFinishInflate();
Log.d(“mDebug”, “onFinishInflate”);
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
// TODO Auto-generated method stub
super.onSizeChanged(w, h, oldw, oldh);
Log.d(“mDebug”, “onSizeChanged,w=”+w+”,h=”+h+”,oldw=”+oldw+”,oldh=”+oldh);
}
}
结果:
12-05 22:23:03.587: D/mDebug(9715): TestView context, attrs=@2131034112
12-05 22:23:03.597: D/mDebug(9715): onFinishInflate
12-05 22:23:03.667: D/mDebug(9715): onSizeChanged,w=240,h=282,oldw=0,oldh=0
12-05 22:23:03.727: D/mDebug(9715): onDraw
12-05 22:23:03.757: D/mDebug(9715): onDraw
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/38770.html