Android布局match_width
Android Layout match_width
Android
中是否有设置 LinearLayout
的高度以匹配其宽度的方法?
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="MATCH_WIDTH_OF_THIS_LinearLayout"
我有 LinearLayout
到 match_parent
的宽度,我希望这个 LinearLayout
与其高度匹配它自己的宽度。
是的,通过使用
android:adjustViewBounds(true);
在java内容布局之前的代码中设置宽度,例如onCreate。
使用 myLayout.getWidth()
获取 LinearLayout 的宽度并将其高度设置为该值。您需要在 onCreate 中执行此操作。
Android: get width of Layout programatically having fill_parent in its xml
Android: How to Programmatically set the size of a Layout
Android
中是否有设置 LinearLayout
的高度以匹配其宽度的方法?
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="MATCH_WIDTH_OF_THIS_LinearLayout"
我有 LinearLayout
到 match_parent
的宽度,我希望这个 LinearLayout
与其高度匹配它自己的宽度。
是的,通过使用
android:adjustViewBounds(true);
在java内容布局之前的代码中设置宽度,例如onCreate。
使用 myLayout.getWidth()
获取 LinearLayout 的宽度并将其高度设置为该值。您需要在 onCreate 中执行此操作。
Android: get width of Layout programatically having fill_parent in its xml
Android: How to Programmatically set the size of a Layout