iOS Question Drawing Bitmap on Canvas

walterf25

Expert
Licensed User
Longtime User
Hi Everyone, i need some help, maybe i'm missing something, but i am working on a Range SeekBar CustomView and i need to draw a bitmap using the Canvas or B4XCanvas classes, everything seems fine until i call the Rect.Initialize(pnlHighlighted) method.

Please refer to the two images attached, the first image shows basically 2 panels inside the mBase panel in the CustomView class.
You Will see a panel with black borders which is the Parent Panel, inside this panel i am adding another panel which is the pnlHighlighted panel in which i need to draw the highlighted slide bar bitmap so that It can track the position of either the left knob or the right knob.

This is where i set the pnlhighlighted size parameters.
Panel Parametes:
pnlhighlighted.SetLayoutAnimated(0,0,parent.Left, parent.top, parent.Width,parent.Height)
And this is where I add the panel to the parent view.
B4X:
parent.AddView(pnlhighlighted, 0, 0, parent.Width, parent.Height)

The issue i'm seeing is that as soon as I call this method.
Canvas Initialization:
''Canvas to draw the highlighted slidebar bitmap
cvshighlighted.Initialize(pnlhighlighted)
The second image shows what the issue is, as you can see the height of the parent and pnlhighlighted panels decrease, even though the pnlhighlighted panel is the same size as the parent panel when it's added to the parent panel.

Why is this happening, does anyone have any suggestions, I know there must be something i must be doing wroing, but can't figure out what.

Has anyone came across this issue and how this you solve it?



Thanks,
Walter
 

walterf25

Expert
Licensed User
Longtime User
Have you tried
pnlhighlighted.SetLayoutAnimated(0, 0, 0, 0, parent.Width,parent.Height)
Hi Klaus, yes and it gives me the same results.

Walter
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
Can you post your project, or a small one showing the problem?
It would be easier to find what is going wrong.
What i just realized is that the Base_resize sub gets called twice, the first time, the width and height are correct and the second time is when the width and height change
But this only happens when cvshighlightedpanel.initialize(pnlhighlighted) is called.

See the logs below, 54 is the correct height of the parent panel but then it gets resized to around 33 after calling the canvas Initialization method.
base_resize: 317.684326171875 -- 54
base_resize: 319.6754150390625 -- 33.19474792480469

I will try to upload a small sample project later on today.
Walter
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
Can you post your project, or a small one showing the problem?
It would be easier to find what is going wrong.
So i ended up unchecking the Handle Resize Event in the Layout file, this seems to fix it, though not sure if this will have any other issues going forward if i decide to add other views to the layout.

Thanks for the Help Klaus.

Walter
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…