tags:

views:

1082

answers:

2

The documentation at http://code.google.com/android/reference/android/widget/AbsoluteLayout.html says:

onLayout(boolean changed, int l, int t, int r, int b)
//Called from layout when this view should assign a size and position to each of its children.

So I overrode it like this:

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
 Log.d("test", "In MainLayout.onLayout");
 int childCount = getChildCount();
 for (int childIndex = 0; childIndex < childCount; childIndex++) {
  getChildAt(childIndex).setLayoutParams(new LayoutParams(100, 100, 100, 100));
 }
 super.onLayout(changed, l, t, r, b);
}

I am declaring the child elements (buttons) in the XML for the layout.

This correctly sets the position of the buttons but not the size. The size is being taken from what is defined in the XML (it's a required attribute).

A: 

Can you post your layout xml?

Neil D
+1  A: 

On your link it also says

This class is deprecated.

Don't spent time making something work that is going to be dropped.This class is deprecated.

Snowwire