Hallo,
With the following code I draw 3 small images into three imv's. Maybe the code is too complicated, but it works. Because of the variation in the width/height ratio of the images the imv's do not always have the same width.
So, when an image must be displayed with another width/height ratio the existing imv must be destroyed and a new one with the required dimensions must be created. Otherwise part of the larger previous image stays visible. I tried it with removing the 'old' imv and initializing en adding a new one, but it doesn't work; part of the old one stays visible.
Can somebody help me?
With the following code I draw 3 small images into three imv's. Maybe the code is too complicated, but it works. Because of the variation in the width/height ratio of the images the imv's do not always have the same width.
So, when an image must be displayed with another width/height ratio the existing imv must be destroyed and a new one with the required dimensions must be created. Otherwise part of the larger previous image stays visible. I tried it with removing the 'old' imv and initializing en adding a new one, but it doesn't work; part of the old one stays visible.
Can somebody help me?
B4X:
Dim imvWidth As Int
Dim imvLeft As Int
Dim bmpPhoto As Bitmap
Dim csvPhoto As Canvas
Dim imvPhoto1,imvPhoto2, imvPhoto3 As ImageView
Dim rectPhoto, rectView As Rect
If File.Exists("/storage/extSdCard/POI-PHOTOS/",CurPhoto1 & ".jpg") Then
bmpPhoto.Initialize("/storage/extSdCard/POI-PHOTOS/",CurPhoto1 & ".jpg")
imvWidth=(bmpPhoto.Width/bmpPhoto.height) * 155
imvLeft=960-imvWidth
imvPhoto1.Initialize("")
imvPhoto1.Bitmap=bmpPhoto
Activity.AddView(imvPhoto1,imvLeft,5,imvWidth,155)
csvPhoto.Initialize(imvPhoto1)
rectPhoto.Initialize(0,0,bmpPhoto.width,bmpPhoto.height)
rectView.Initialize(0,0,imvWidth,155)
csvPhoto.DrawBitmap(bmpPhoto,rectPhoto, rectView)
End If
If File.Exists("/storage/extSdCard/POI-PHOTOS/",CurPhoto2 & ".jpg") Then
bmpPhoto.Initialize("/storage/extSdCard/POI-PHOTOS/",CurPhoto2 & ".jpg")
imvWidth=(bmpPhoto.Width/bmpPhoto.height) * 155
imvLeft=960-imvWidth
imvPhoto2.Initialize("")
imvPhoto2.Bitmap=bmpPhoto
Activity.AddView(imvPhoto2,imvLeft,166,imvWidth,155)
csvPhoto.Initialize(imvPhoto2)
rectPhoto.Initialize(0,0,bmpPhoto.width,bmpPhoto.height)
rectView.Initialize(0,0,imvWidth,155)
csvPhoto.DrawBitmap(bmpPhoto,rectPhoto, rectView)
End If
If File.Exists("/storage/extSdCard/POI-PHOTOS/",CurPhoto3 & ".jpg") Then
bmpPhoto.Initialize("/storage/extSdCard/POI-PHOTOS/",CurPhoto3 & ".jpg")
imvWidth=(bmpPhoto.Width/bmpPhoto.height) * 155
imvLeft=960-imvWidth
imvPhoto3.Initialize("")
imvPhoto3.Bitmap=bmpPhoto
Activity.AddView(imvPhoto3,imvLeft,326,imvWidth,155)
csvPhoto.Initialize(imvPhoto3)
rectPhoto.Initialize(0,0,bmpPhoto.width,bmpPhoto.height)
rectView.Initialize(0,0,imvWidth,155)
csvPhoto.DrawBitmap(bmpPhoto,rectPhoto, rectView)
End If
End Sub