定制的ViewGroup的例子吗? [英] custom viewgroup example please?

查看:103
本文介绍了定制的ViewGroup的例子吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索在这里SO,谷歌,对android文档...

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

但我找不到code单段自定义的ViewGroup的例子,我觉得顶多一些模糊的解释...

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

有人可以提供吗?你如何做一个ViewGroup中,你可以把它的孩子,你想要什么?

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

<一个href="https://github.com/android/platform_frameworks_base/blob/master/core/java/android/widget/AbsoluteLayout.java" rel="nofollow">https://github.com/android/platform_frameworks_base/blob/master/core/java/android/widget/AbsoluteLayout.java

您需要重写onMeasure来衡量孩子,onLayout进行定位。

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

我有显着更复杂的ViewGroup code,我可以分享,如果你想为好。

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

这篇关于定制的ViewGroup的例子吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆