Android RelativeLayout below 2 views

前端 未结 3 586
孤城傲影
孤城傲影 2021-02-04 23:46

I have a RelativeLayout like this:



        
3条回答
  •  南方客
    南方客 (楼主)
    2021-02-05 00:10

    The answer here requires very little change. You had most of your layout correct, however, there is one option messing everything up. AlignParentXXXX will often take a "false" priority over your LayoutXXXX options. So, by setting your Button to AlignParentBottom, you are telling the RelativeLayout that the Button's size is not calculated in the parent layout size.

    You may resolve the issue by simply removing AlignParent="true" from your Button. The result code is below and tested. This solution keeps in line with your desires, I believe.

    
    
        
        
        
        

    I ran into many similar issues with AlignParent when WrapContent was on the Parent. Top and Bottoms positioning creates undesired behavior if not prepared for it. I find, in general, it is best to use only one or the other (if at all) and line up the rest above or below that.

提交回复
热议问题