0

反正Android中有沒有設置LinearLayout的高度以匹配它的寬度?Android Layout match_width

<LinearLayout 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="MATCH_WIDTH_OF_THIS_LinearLayout" 

我有LinearLayoutmatch_parent的寬度,我想這LinearLayout爲它的高度匹配它自己的寬度。

回答

0

是有,通過在Java代碼使用

android:adjustViewBounds(true); 
+0

不能看到[LinearLayout.LayoutParams]該參數(https://developer.android.com/reference/android/widget/LinearLayout.LayoutParams.html) – Onik

0

設定寬度之前的內容已被佈局,如的onCreate。