我有一個帶有兩個子視圖的LinearLayout(垂直)。第一個是ScrollView,第二個是Visibility.GONE的另一個佈局,它的大小不固定(由其子節點決定)。Android:如何確定視圖的新大小
<LinearLayout vertical>
<ScrollView> ... </ScrollView>
<AnotherLayout visibility=GONE height=wrap_content> ... </AnotherLayout>
</LinearLayout>
在某個時間點我想顯示AnotherLayout。但是,一旦彈出,我也想調整ScollView的滾動。爲此,我需要知道這個AnotherLayout的大小。
我在做這樣的事情:
int oldHeight = scrollArea.getHeight();
linearLayout.setVisibility(VISIBLE);
int newHeight = scrollArea.getHeight();
但oldHeight和newHeight仍然是相同的。
我該如何計算新的身高?
正是我所需要的,以及 –
可能的複製[獲取設置包內容佈局的高度(HTTP: //stackoverflow.com/questions/35122998/get-height-of-layout-that-is-set-to-wrap-content) –