在開發中如果你的xml文件的跟布局是ScrollView,在ScrollView中無論你寫什么樣的布局,其默認情況下都是不能填充整個布局的。也就是說你的ScrollView中的子布局設置fill_parent不起作用。
解決辦法:
在ScrolllView控件中加上android:fillViewport="true"則問題解決。
官方文檔的解釋:
Indicates this ScrollView whether it should stretch its content height to fill the viewport or not. 表明這ScrollView是否應該延伸其內容高度來填補視窗。
下面是網上的一段解釋:
ScrollView里只放一個元素. 當ScrollView里的元素想填滿ScrollView時,使用"fill_parent"是不管用的,必需為ScrollView設置:android:fillViewport="true"。 當ScrollView沒有fillVeewport=“true”時, 里面的元素(比如LinearLayout)會按照wrap_content來計算(不論它是否設了"fill_parent"),而如果LinearLayout的元素設置了fill_parent,那么也是不管用的,因為LinearLayout依賴里面的元素,而里面的元素又依賴LinearLayout,這樣自相矛盾.所以里面元素設置了fill_parent,也會當做wrap_content來計算.