Search code examples
androidandroid-layoutandroid-linearlayoutandroid-layoutparams

Android Layout match_width


Is there anyway in Android to set the height of the LinearLayout to match it's width?

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

I have the LinearLayout to match_parent's width, and I want this LinearLayout to match it's own width for it's height.


Solution

  • Yes there is, by using

    android:adjustViewBounds(true);