写布局文件时,发现即便LinearLayout的高度适配为match_parent , 嵌套模式如下:
<LinearLayout>
<ScrollView> //match_parent
<LinearLayout> //height:0 ,weight:1
<ListView> //wrap_content
</LinearLayout>
<Button>
</ScrollView>
</LinearLayout>
需求时Button显示在底部,ListView外布局自适配高度,因为整体高度受底部NegavitionBar影响,为保持button在底部。但发现,此时,所有控件高度的计算都是wrap_content,一旦隐藏底部negavitionBar, button就自动上移高度。
排查后,原来时需要在ScrollView中添加android:fillViewport="true"属性。