add imageview half manually

Paladium

Member
Licensed User
Longtime 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
Longtime 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

B4X founder
Staff member
Licensed User
Longtime 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

Paladium

Member
Licensed User
Longtime User
Thanks for the help. Didn't know that I can load a layoutfile in a scrollview, too.

Thanks again.:sign0098:
 
Upvote 0

klaus

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

Best regards.
 

Attachments

  • ImageScrollView.zip
    186.3 KB · Views: 3,461
  • ImageScrollView.jpg
    ImageScrollView.jpg
    44.6 KB · Views: 33,131
Upvote 0

Paladium

Member
Licensed User
Longtime 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
Top