android opposite of bringChildToFront
android, android-view
Solution
There is no such method in native android API. But you can implement it by yourself, here is an example:
public void moveChildToBack(View child) {
int index = indexOfChild(child);
if (index > 0) {
detachViewFromParent(index);
attachViewToParent(child, 0, child.getLayoutParams());
}
}
This method will work only in sub-classes of android.view.ViewGroup class, because it uses protected methods.
The main idea is to move your child view to the first place in child list, because ViewGroup uses natural order of it child's to draw them, which means first view in list will have lowest Z-order, and last view will have highest Z-order.
Problem
is there a method which does the opposite of bringChildToFront. I want to send the child to back. How can I do that?