Hello,
I'm having some issues with stretching/fitting an image in an ImageView. Also i'm using LoadBitmapSample to load it. I need them to nicely in BetterSlidingPanels.
Here is my code:
Right now with Gravity.Center i get this:
But i want to lose the top and bottom blank space.
And with Gravity.Fill i get this:
And that distorts/stretches the image, and it doesn't look natural.
I want to fit it like this:
Not sure if the Gravity can help, but 100%x and 100%y doesn't make the image fit on the screen.
I'm having some issues with stretching/fitting an image in an ImageView. Also i'm using LoadBitmapSample to load it. I need them to nicely in BetterSlidingPanels.
Here is my code:
B4X:
Sub Activity_Create(FirstTime As Boolean)
Dim panels(15) As Panel
For i = 0 To panels.Length - 1
panels(i).Initialize("panels")
Dim imga As ImageView
imga.Initialize("")
imga.Bitmap = LoadBitmapSample(File.DirAssets, "picture" & i & ".jpg", 100%x, 100%y)
imga.Gravity = Gravity.Center
panels(i).AddView(imga,0,0,100%x,100%y)
Activity.AddView(panels(i), 100%x, 0, 100%x, 100%y)
Next
ActiveBitmap.Initialize(File.DirAssets, "indicator_active.png")
InactiveBitmap.Initialize(File.DirAssets, "indicator_inactive.png")
sd.Initialize
SlidingPanels.Initialize(sd, panels, True, 50)
sd.currentPanel = currentPanelBeforePaused - 1
Indicator = SlidingPanels.CreatePageIndicator(panels.Length, InactiveBitmap, 120dip, 16dip)
Activity.AddView(Indicator, (100%x - 120dip) / 2, 0, 120dip, 16dip)
Indicator.BringToFront
ChangePanel(0)
End Sub
Right now with Gravity.Center i get this:
But i want to lose the top and bottom blank space.
And with Gravity.Fill i get this:
And that distorts/stretches the image, and it doesn't look natural.
I want to fit it like this:
Not sure if the Gravity can help, but 100%x and 100%y doesn't make the image fit on the screen.