Please take a look at this xml layout.
<LinearLayout android:id="@+id/dataTableContainer" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:clipChildren="true"> <LinearLayout android:id="@+id/dataTable" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"/> </LinearLayout>
At runtime the "dataTable" element is populated with children that are wider than what the "dataTableContainer" can display. However, as I inspect in eclipse the mMeasuredWidth of the two elements (or even the return value of getWidth()), they turn out to be exactly the same. This shouldn't be the case. My understanding is that the children of "dataTable" should push it to assume their own width given its "wrap_content" setting. Conversely, "dataTableContainer" should be smaller than that, given its "fill_parent" setting which is constrained by the screen size.
I've also tried with "clipChildren" set to false, just in case the width gets clipped by the container but the result remain the same: both table and container have the same width.
Can anybody explain what's going on?
To give you some context, what I'm trying to do is to gather the sizes of these elements to determine how much of the "dataTable" element lies -outside- of the container and therefore unseen. This in turn is needed to limit how far the user can drag the table element. ScrollView elements limit the motion natively, but as I'm using a LinearLayout I need to replicate that limiting functionality.View original question