Android RelativeLayout and height of wrap_content?

前端 未结 2 764
挽巷
挽巷 2021-02-10 09:30

I am trying to make a selection ListActivity, similar to the one used to add shortcuts to the launcher screens. I have rolled my own header and footers, which I would like to be

2条回答
  •  庸人自扰
    2021-02-10 10:12

    According to the developer documentation your desired behaviour is not possible for Relative layout ;

    "Note that you cannot have a circular dependency between the size of the RelativeLayout and the position of its children. For example, you cannot have a RelativeLayout whose height is set to WRAP_CONTENT and a child set to ALIGN_PARENT_BOTTOM."

    RelativeLayout

    To solve your problem you could maybe try to use a linear layout, set to wrap_content and set max height via code to screen height.

    You can get the screen height as described here : get screen height

提交回复
热议问题