开发者

Android: Control Hierarchy in Custom Components

开发者 https://www.devze.com 2023-01-18 23:22 出处:网络
I\'m reading the android docs on custom component development and i\'m a little confused. If you\'re creating an activity, you can add add a hierarchy of views via setContent. however, if you\'re crea

I'm reading the android docs on custom component development and i'm a little confused. If you're creating an activity, you can add add a hierarchy of views via setContent. however, if you're creating a custom component, you have to handle everything in the draw() overload.

if i want to build a custom component that relies on a view hierarchy, is the model simply to create a hierarchy internally and then in draw call myViewHierarchy.Draw()开发者_开发技巧 or something?


however, if you're creating a custom component, you have to handle everything in the draw() overload.

Not necessarily. That's one approach, but hardly the only one.

if i want to build a custom component that relies on a view hierarchy, is the model simply to create a hierarchy internally and then in draw call myViewHierarchy.Draw() or something?

No. Just add children to a container, then add logic to the container for representing the composite widget. For example, I have a ColorMixer custom component that combines three SeekBars, three TextViews (labels for the SeekBars), and a plain View (used to provide a color swatch).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号