Android layout_width & layout_height, how it works?

前端 未结 3 1268
梦毁少年i
梦毁少年i 2020-12-16 06:11

I am trying to create an interface, where two or more buttons will be displayed to the user, if a button is clicked, some Layouts will be displayed to him. I am using the

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-16 06:43

    The layout_width and layout_height properties of a view are intended to be used by its parent container. Some containers ignore one or both of these; most honor them. You need to consult the documentation of the container (in your case, SlidingDrawer) to understand how the values will be used.

    You don't show the complete main.xml, so it's hard to say exactly what's going wrong. It would also help if you posted an image of what's wrong.

    EDIT

    After seeing your complete layout, I think that the basic problem here is that you are using a LinearLayout to contain the SlidingDrawers. As the docs for SlidingDrawer note, they need to be in either a FrameLayout or a RelativeLayout (actually, any container that allows multiple views to sit on top of one another).

    Another possibility is that the second SlidingDrawer is being placed directly under the first one. Try changing the size of the second button (e.g., make the text longer) and see if it pokes out on either side of button 1.

提交回复
热议问题