Question

We can draw approximately all things in canvas in onDraw method of a customview.Also Docs say:

When you want to dynamically draw some two-dimensional graphics, a ShapeDrawable object will probably suit your needs.

My question is simple,when we have to use custom view and when ShapeDrawable?Or it is best we combine them?if it is true,What is the strengths and weaknesses of these options?

Was it helpful?

Solution

Well, i think ShapeDrawable is easier to use, cause you can use it in Selector, for example, and create button with custom background and click animation without writing any code at all (just using XML). On the other hand, this drawables are pretty limited, and if you need your own control with non-standart tuch interception you defenatelly must create your own custom View.

So i think it's better to combine them, because somtimes you need something simple and ShapeDrawables is real fast and good solution for it, but if you want something real speccial OR something that you can archive using shapes, here you must write your own View.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top