ViewGroup中bringToFront
bringToFront就是把当前View提到画面图层的最上面来显示
public void bringToFront() {
if (mParent != null) {
mParent.bringChildToFront(this);
}
}
Android中的ViewGroup是通过一个Array来保存其Children,当调用某个childView的bringToFront时,是将该childView放在其Parent的Array数组的最后面。逆序调用显示
@Override
public void bringChildToFront(View child) {
final int index = indexOfChild(child);
if (index >= 0) {
removeFromArray(index);
addInArray(child, mChildrenCount);
child.mParent = this;
requestLayout();
invalidate();
}
}