views:

27

answers:

1

I have a ViewFlipper that is transitioned between each view, I want to draw animation to a set of canvases, one for each view. How would I go about integrating the canvas into the view so that I can still have my buttons on top of it for example?

If this isn't possible, how would I go about making images drawn to the canvas clickable so i can construct my own buttons?

A: 

It seems I'm making a habit of answering my own questions, but anyway, I'm doing it only for the sake of completion and hopefully others that might come across the problems I have when learning the android platform.

The way, it seems to have a canvas included in your view is to create a custom view.

Your custom view should extend View (the android one) and should then be instantiated in your layout.

Instantiating it in the layout must be done the complete way as follows.

if your package name is:

com.mypackage

and your custom view class is called

MyCustomView

then your instantiation in the layout XML should be as follows

<com.mypackage.MyCustomView
android:id="myviewid" android:layout_height="fill_parent"
android:layout_width="fill_parent">
</com.mypackage.MyCustomView>

I have included some parameters there such as the ID and the layout (I make it fill parent because I want it full screen) and then I just place that part somewhere iniside my RelativeLayout above other things like buttons which means it will be underneath them on the screen.

Hope this helps someone else, enjoy.

Hamid