ViewGroup.layout(int l, int t, int r, int b)四个输入参数的含意

本文详细介绍了Android中View的layout方法,该方法用于确定View及其子View的大小和位置。这是布局机制的第二阶段,在这一阶段,每个父View都会调用其所有子View的layout方法来定位它们。通常使用在测量阶段存储的子View尺寸来进行此操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Open Declaration void android.view. View.layout(int l, int t, int r, int b)

Assign a size and position to a view and all of its descendants

This is the second phase of the layout mechanism. (The first is measuring). In this phase, each parent calls layout on all of its children to position them. This is typically done using the child measurements that were stored in the measure pass().

Derived classes should not override this method. Derived classes with children should override onLayout. In that method, they should call layout on each of their children.

Parameters:
l Left position, relative to parent
t Top position, relative to parent
r Right position, relative to parent
b Bottom position, relative to parent

            /**
             *  l Left position, relative to parent    控件左边 距离左边的距离
                t Top position, relative to parent            控件上边距离上边的距离
                r Right position, relative to parent   控件右边距离左边的距离
                b Bottom position, relative to parent  控件下面距离上边的距离
             */
           

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值