tags:

views:

45

answers:

2

I have a LinearLayout with fixed view. I dynamically inject images in it (ImageViews) but I dunno in advance how many of them will be inserted. I'd like to have a layout where images wrap and go to a new line authomatically when they exceed the available width of the father (LinearLayout)

how do you recommend I should move?

thanks a lot

A: 

Define a Listview within the Linear Layout like below. Wrap your Linear Layout tags around it.

<ListView
    android:id="@android:id/list" 
    android:layout_width="fill_parent" 
    android:layout_height="0dp"
    android:layout_weight="1"
    android:drawSelectorOnTop="false"
    android:scrollbarAlwaysDrawVerticalTrack="true" 
/>

Update this list view dynamically as you add images. This will solve your issues.

Vishwanath
A: 

As I answered on a question asked a couple of hours before yours:

There is no layout manager in Android today that behaves like Swing's FlowLayout, where it wraps widgets onto multiple lines. It is theoretically possible for you to write one yourself, by looking at the open source code for LinearLayout, etc. and following the patterns they establish.

Sorry!

CommonsWare