ImageView in the Designer

alfcen

Well-Known Member
Licensed User
Longtime User
When I add an ImageView in the Designer it shows up correctly
but any attempt to assign it a bitmap fails. However, when I add
the ImageView programmatically, for instance

B4X:
Activity.AddView(ImageView1, 60%x, 8%y, 100dip, 100dip)

then it does load the bitmap formidably in either way:

ImageView1.Bitmap = Bitmap, or ImageView1.Bitmap = LoadBitmap(...)

Did I miss something?
 

alfcen

Well-Known Member
Licensed User
Longtime User
Thanks Andrew. I did declare the ImageView under Globals and also tried "Generate Members" - no change. Anyway, it is easy to work around.
 

agraham

Expert
Licensed User
Longtime User
but any attempt to assign it a bitmap fails.
Do you mean in the Designer? It works fine for me :confused:

You need to add the image to the image pane with the "Add Images" button and it should then show up for selection up in the "Image File" dropdown in "ImageView properties".
 

alfcen

Well-Known Member
Licensed User
Longtime User
Right, Andrew, it does work in the Designer. Perhaps, if you add an ImageView in the Designer you must add an image to it in the Designer, too.

If you want to assign an image to an ImageView in the code, you should not create the ImageView in the Designer, but in the code only, such as with

Dim ImageView1 As ImageView
Activity.AddView(ImageView1, 0, 0, 100dip, 100dip), and then,
ImageView1.Bitmap = (...)

So, I believe you can either work with the Designer or in the code. In a way, that would make sense.
 

agraham

Expert
Licensed User
Longtime User
Perhaps, if you add an ImageView in the Designer you must add an image to it in the Designer, too.
No, you can add the ImageView in the Designer, without an image, and assign images to it in code as long as you have declared in it Globals so the compiler knows it is there. The Designer Generate Members will do that for you but you need to tick the ones you require.
 

susu

Well-Known Member
Licensed User
Longtime User
Haha I just know I can insert image by Designer, I'm so stupid :D
 
Top