Android Question How to add Image in Horizontal scrollview

junaidahmed

Well-Known Member
Licensed User
Longtime User
I have used Scrollview to add List of Image in Scrollview Panel.I would like to know how to add Image in Horizontal scrollview.Please provide me example....
 

Star-Dust

Expert
Licensed User
Longtime User
It's the same, obviously it does not have to advance the Top position but Left.

B4X:
FOR I=0 to Image.Size - 1
ScrollView.Panel.AddView(Image(i), i * width, 0, width, height)
Next
 
Last edited:
Upvote 0

junaidahmed

Well-Known Member
Licensed User
Longtime User
I have used below code using "Map" but its showing only one image please check the below code and advise the same....
B4X:
Sub CmdBrowse_Click
   
   
    Ret = Fd.Show("Diary", "OK", "Cancel", "", Null)  
    If Ret = DialogResponse.POSITIVE Then
        StrFldName = Fd.FilePath & "/"
        StrFileName = Fd.ChosenName
        Bitmaps.Put(StrFileName,StrFldName)
        AddThumNailImage(Bitmaps)
    End If
       
Sub AddThumNailImage (PicMap As Map)
   
    For i =0 To PicMap.Size-1
        Dim ImgThum As ImageView
        ImgThum.Initialize("")
        ImgThum.Bitmap= LoadBitmapResize(PicMap.GetValueAt(i),PicMap.GetKeyAt(i), 100%x,100%y,True)
                HorizontalScrollView1.Panel.AddView(ImgThum, 5dip, 5dip + i * 200dip, 70 - 10dip, 190dip)
    Next
   
   
End Sub
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Add

HorizontalScrollView1.Panel. Widht=(i + 1) * 200dip

B4X:
Sub AddThumNailImage (PicMap As Map)
 
    For i =0 To PicMap.Size-1
        Dim ImgThum As ImageView
        ImgThum.Initialize("")
        ImgThum.Bitmap= LoadBitmapResize(PicMap.GetValueAt(i),PicMap.GetKeyAt(i), 100%x,100%y,True)
        HorizontalScrollView1.Panel.AddView(ImgThum, 5dip + i * 200dip, 5dip, 70dip - 10dip, 190dip)
        HorizontalScrollView1.Panel. Widht=(i + 1) * 200dip
    Next

End Sub
 
Last edited:
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Thanks would have been enough :rolleyes:
a like welcome :D
100 bitcoin dreamed :p
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
i think you stack set the position in y and not at x axis
HorizontalScrollView1.Panel.AddView(ImgThum, 5dip, 5dip + i * 200dip, 70 - 10dip, 190dip)
 
Upvote 0
Top