Search code examples
androidbackgroundforeground

change an imageView to foreground and background in Android


I have two ImageViews imageView1, imageView2 and they are partially intersected, I want with an OnClick or onTouch on one of theme it will be on foreground and the other one at the background relative to the other one and vice versa.

I just need the function like setOnForeGround (which does not exist) to call it for this raison.

Thanks.


Solution

  • If they have the same parent, you should be able to use View.bringToFront() on either ImageView to bring it to the foreground.