mit-cml / appinventor-sources

MIT App Inventor Public Open Source
http://appinventor.mit.edu/appinventor-sources/
Apache License 2.0
1.49k stars 2.08k forks source link

Arrangement fill parent not reserving enough size #326

Open halatmit opened 9 years ago

halatmit commented 9 years ago

I'm not sure what the root cause is, but a vertical arrangement of height fill parent sitting inside a horizontal arrangement of height automatic doesn't seen to be doing the right thing.

The following project illustrates the bug

people.csail.mit.edu/hal/misc/horizVertsizeBug.aia

hasitpbhatt commented 9 years ago

@halatmit , wrap_content only takes minimum area required, and fill parent fills the whole area it's parent has.

http://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html#FILL_PARENT

And consider it a concept or bug, layout containing,

<LinearLayout android:layout_height="wrap_content" android:layout_width="wrap_content"

    <Button 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="haha"
        />

    <LinearLayout 
        android:layout_height="fill_parent"
        android:layout_width="wrap_content"
        android:orientation="vertical"
        >

        <Button 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="text1"
        />
        <Button 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="text2"
        />
        <Button 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="text3"
        />

    </LinearLayout>

</LinearLayout>

is not working properly in android.

williamhub commented 9 years ago

@halatmit In the aia project, the Horizontal Arrangement's layout height is stetted as Automatic, and the inner Vertical Arragement's layout height is stetted as Fill Parent.

In the below explanation from source code, it says that actual height of the horizontal arrangement is determined by the tallest component whose height property is not set to Fill Parent.

In this project, because there is a button, whose height property is Automatic, in the Horizontal Arrangement layout, the height of horizontal arrangement is determined by button then instead of inner Vertical Arrangement

https://github.com/mit-cml/appinventor-sources/blob/4a18ef5dd41114ad68353c6f7e0037ad94dc755d/appinventor/appengine/src/com/google/appinventor/client/editor/simple/components/MockHVLayoutBase.java