Android Question Creating a fluid list of icons with xcustomlistview

wimpie3

Well-Known Member
Licensed User
Longtime User
I'm currently using xcustomlistview with a panel containing three imageviews to show a grid of 3x... icons. However, this shows 3 images in a row all the time, which is not what I want.

Is there a way to make this grid completely fluid on all resolutions automatically? With "fluid" I mean that when the resolution increases, the number of images on one line in the imagelist increases as well.

Do I really need to make separate layouts for every resolution and manage all this myself, or is there a way to make a completely fluid grid which is resolution independent, meaning that on large screens there can be like 5 images in a row, but on low resolution screens maybe 2, depending on the size of the image.
 

John Naylor

Active Member
Licensed User
Longtime User
Get your screen size, decide how many images in a row should be shown, then generate a panel with that number of images in your code.

I've just done similar with Simple Media Manager.

I wanted to start my view with a single strip of images but also allow the user to select a view of 2, 3, or 4 columns.

A simple loop took care of generating the relevant number of images shown on the parent panel.
 
Last edited:
Upvote 0

John Naylor

Active Member
Licensed User
Longtime User
I'm not near my PC right now but it went something like this


B4X:
    Dim panel1 As Panel = xui.CreatePanel("")
    Dim cols As Int
    
    For cols = 0 To 5                                                'Whatever number of images you want
        Dim img As ImageView       
        img.Initialize ("myImage" & cols)                            'Each image gets an event of mYimage0, myImage1
                                                                    'Skip the & cols to assign the same event to each image
                                                                    
        panel1.AddView (img, (cols * 200), 0, 200dip, 200dip)        'Layout your views on your panel
    Next
 
Upvote 0
Top