自定义ViewGroup示例? [英] custom ViewGroup example?
问题描述
我在Google,Android文档上的SO上进行了搜索...
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?
推荐答案
我认为最简单的示例是AbsoluteLayout.java的来源
I think the simplest example to look at is the source for AbsoluteLayout.java
您需要覆盖onMeasure来度量子级,并覆盖onLayout来对其进行定位.
You need to override onMeasure to measure the children and onLayout to position them.
如果您愿意,我也可以共享非常复杂的ViewGroup代码.
I have strikingly more complicated ViewGroup code I can share as well if you want.
这篇关于自定义ViewGroup示例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!