tags:

views:

22

answers:

1

Hi,

I was wondering in what order the following methods - onDraw(), onMeasure(), onSizeChanged() - are called automatically when we create a custom component.

Not sure if this question makes sense ... I've just been kinda confused as to what the methods are supposed to do exactly.

Thanks for the help in advance.

Cheers.

A: 

By custom component, do you mean view? Those will be called automatically. This API for View might be helpful to you, particularly the section "implementing a custom view".

onDraw(Canvas) Called when the view should render its content.

onMeasure(int, int) Called to determine the size requirements for this view and all of its children.

onSizeChanged(int, int, int, int) Called when the size of this view has changed.

As it says, to start with you can just implement onDraw, then worry about the others if you need to do something special.

Mayra