custom ViewGroup example?

烂漫一生 提交于 2019-11-27 20:34:15

问题


I searched here on SO, on Google, on the android docs...

But I cannot find a single snippet of code with a example of custom viewgroup, I find at most some vague explanations...

Can someone provide one? How you make a viewgroup where you can put its children where you want?


回答1:


I think the simplest example to look at is the source for AbsoluteLayout.java

https://github.com/android/platform_frameworks_base/blob/master/core/java/android/widget/AbsoluteLayout.java

You need to override onMeasure to measure the children and onLayout to position them.

I have strikingly more complicated ViewGroup code I can share as well if you want.



来源:https://stackoverflow.com/questions/5663068/custom-viewgroup-example

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!