Is there any way to have UI elements slightly overlap (one on top of one another) without using absolute layouts?

后端 未结 3 1634
渐次进展
渐次进展 2021-01-19 17:40

Lets say I have a list on screen, which I always want to be usable. I also want a small image or textview to slightly overlap the listview. Is anything this possible without

相关标签:
3条回答
  • 2021-01-19 18:21

    As well as RelativeLayouts, you can also use FrameLayouts to stack objects. Other than the z-order (last object declared = highest z-order), the child objects don't depend on the positioning of other objects in the group, so you can just set margins or gravity to position them.

    So in your instance, just declare a TextView after your ListView, and position it wherever you want. It won't interfere with the ListView's positioning, and it will sit on top.

    0 讨论(0)
  • 2021-01-19 18:23

    Relative Layouts also allow things to overlap. Views declared later in the xml will be on top. I believe that aligning view edges and use of margins should allow you to achieve this affect without great difficulty.

    0 讨论(0)
  • 2021-01-19 18:26

    You could use RelativeLayout and set for example android:layout_marginTop="-50dip" android:layout_below="@id/my_list".

    0 讨论(0)
提交回复
热议问题