Hi,
I'm trying to make a compound control which looks like the following:
<LinearLayout>
<ImageView />
<ImageView />
...
</LinearLayout>
I want to fill a horizontal linear layout with as many image views as
possible - but only a single row of them. I'm not sure where to add
the image views to the layout at runtime, I am getting inconsistent
results, for example:
class Foo extends LinearLayout {
void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, r, t, b);
addAsManyImageViewsAsCanFit(r-l);
}
void addAsManyImageViewsAsCanFit(int width) {
while (we can fit more) {
ImageView iv = new ImageView(getContext());
iv.setLayoutParams(...);
addView(iv);
}
}
}
I'm sure image views are getting added as child views, but they don't
always take up space in the layout somehow (I'm giving them a fixed
width and height for now). Where should I be adding the image views to
the layout? onLayout? onSizeChanged? After adding each one, do I need
to call requestLayout() or some other method on the parent?
Thanks
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en