Layout Layers? Z-Axis?

后端 未结 2 436
眼角桃花
眼角桃花 2020-11-29 05:22

I have seen numerous applications that use layering in their layouts. When I speak of layering I am referring to layers in the z-axis relative to the view of the user. One s

相关标签:
2条回答
  • 2020-11-29 05:53

    Small addition to previous answer: to prevent onClick events on bottom "layer" set attribute clickable="true" to top "layer"

    <RelativeLayout
    ....
    android:clickable="true"/>
    

    Otherwise, buttons on something with "click" events can be pressed through top layer.

    I found this issue when I have tried to cover UI by RelativeLayout layer with half-transparent background.

    0 讨论(0)
  • 2020-11-29 06:02

    Try using FrameLayout.

    FrameLayout always places things one on top of the other and always in reference to the upper lefthand corner, so you'll need to use separate layouts inside of FrameLayout to place your objects where you want the on the screen.

    Remember that android will put things into your layout in the order that they are list, so place objects at the bottom of the layout that you want near the top of your display.

    Here's a quick example (don't forget to add proper xml header data to the top node):

    <FrameLayout>
      <RelativeLayout>
        <!--  Place the objects you want on the bottom here -->
      </RelativeLayout>
    
    
      <RelativeLayout>
        <!--  Place the objects you want on the top here -->
      </RelativeLayout>
    </FrameLayout>
    
    0 讨论(0)
提交回复
热议问题