add imageview half manually

Paladium

Member
Licensed User
Hi there,

I have perhaps a dumb question. Can someone tell me how to add an imageview to a scrollview?
I looked at the tutorial, but this isn't general enough.

I put a scrollview on the activity in the designer. I added a lot of images in the designer.

I started:
B4X:
Dim flscroll1 As ScrollView
Dim aa As ImageView
flscroll1.Panel.AddView(aa,20,20,70,50)
aa.Bitmap(????????????(Do not know, added with designer),"a.png")
aa.Gravity = Gravity.CENTER

So, how to easily add manually without the designer imageviews to a scrollview? Just basic things. I need an click-event on each imageview.

Please help. Thanks to all....

Markus
 

Paladium

Member
Licensed User
Especially I would be happy if someone could help me to load image files into the program. I don't know what the designer does, what I do have to do manually for the scrollview. :sign0085:
 
Upvote 0

Erel

Administrator
Staff member
Licensed User
You can create another layout file with the designer and then load it to the ScrollView with:
B4X:
ScrollView1.Panel.LoadLayout("...")

Adding an ImageView programatically:
B4X:
Dim IV As ImageView
IV.Initialize("IV")
ScrollView1.Panel.AddView(IV, ...)
IV.SetBackgroundImage(LoadBitmap(File.DirAssets, "1.jpg")) 'Image added with the designer or File manager.
 
Upvote 0

klaus

Expert
Licensed User
Attached you have an example of a ScrollView with images.

Best regards.
 

Attachments

  • ImageScrollView.zip
    186.3 KB · Views: 3,203
  • ImageScrollView.jpg
    ImageScrollView.jpg
    44.6 KB · Views: 32,782
Upvote 0

Paladium

Member
Licensed User
Thanks for all your good help!!!

Where would you put the Click_event of an imageview in a seperate layout loaded by a scrollview in another activity?

Thanks in advance...

Markus
 
Upvote 0

klaus

Expert
Licensed User
If the other ScrollView is in another activity you must have the ScroolView_Click event in that activity.
But why do you want to have the other ScrollView in another activity, and not keep it in the same activity ?

Best regards.
 
Upvote 0
Top