I have a lot of View
in my Activity
, and I want to make the View
named imageView1
at the Background, the last one, exactly the inverse of imageView1.bringToFront();
Are there any method to call for this raison?
thank you.
I have a lot of View
in my Activity
, and I want to make the View
named imageView1
at the Background, the last one, exactly the inverse of imageView1.bringToFront();
Are there any method to call for this raison?
thank you.
I used a very interesting static function for this, because I searched before and I did not find any method
public static void bringToBack(final View v) {
final ViewGroup parent = (ViewGroup)v.getParent();
if (null != parent) {
parent.removeView(v);
parent.addView(v, 0);
}
}
view.setOnTouchListener(new View.OnTouchListener){
@Override
public boolean onTouch (View v, MotionEvent event){
if (event.getAction() == MotionEvent.ACTION_MOVE) {
view.bringToFront()
} else if (event.getAction() == MotionEvent.ACTION_UP) {
ViewGroup viewGroup = (ViewGroup) view.getParent();
sendToBack(viewGroup, view);
}
}
});
private static void sendToBack(ViewGroup viewGroup, View view) {
if (viewGroup != null) {
viewGroup.removeView(child);
viewGroup.addView(child, 0);
}
}