Android Question programmatically created imageview crashes on accessing <height> property?

vagos21

New Member
Hello everyone

i'm pretty new to all this amazing android dev thingy, and all i can say is congrats to the creators!!!

i have this problem
when i create an imageView in the designer, i can change its width and height with no problem in code
but when i create it programatically...


Dim img1 As ImageView

img1.Initialize("")
img1.Bitmap = LoadBitmap(File.DirAssets, "tr01.jpg")
img1.height = 100dip

it crashes on runtime right on the set height line.

if i try this:
scrollview1.panel.AddView(img1,0,0,100%x, 100%y)

it's all fine, but if i do this...
scrollview1.panel.AddView(img1,0,0,img1.width, img1.height)
i get another crash...

all i'm trying to do is add a few images in a scrollview one after another...
any ideas anyone?

thank you for your time!
 

sorex

Expert
Licensed User
Longtime User
@vagos21 : actually it should be less lines since there's no need to set the size before adding it to the parent, you set the size during the addView ;)
 
Upvote 0
Top