简体   繁体   中英

Android dynamically stacking views

It seems that this issue is pretty confusing to me.

I just want a view to be added on click on top of another one. Something like this:

  • View
  • View
  • View
  • View

Does anyone know how to do this?

That depends on what "on top of another one" means.

If you mean on the Y axis (vertically up the screen), use a vertical LinearLayout .

If you mean on the Z axis (perpendicular to the screen, heading towards the user's eyes), use a FrameLayout or RelativeLayout , where later children are higher on the Z axis than are earlier children. Or, if your minSdkVersion is 21 or higher, you can use the elevation property to control the Z axis positioning.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM