Android Question scalepanel problem

tufanv

Expert
Licensed User
Longtime User
Hello

I am using this code snippet to scale a panel : panelana in my project.

B4X:
Sub ScalePanel(pnl As Panel, factor As Float)
    Dim jo As JavaObject = pnl
    jo.RunMethod("setScaleX", Array(factor))
    jo.RunMethod("setScaleY", Array(factor))
    pnl.Top=pnl.Top+((currentscale-factor)*boy)
    pnl.left=pnl.left+((currentscale-factor)*en)
    currentscale=factor
end sub

this code also centers the panel with adjusting the scaled panel. ( en and boy is 100%x and 100%y which means width and height )

To give you an idea about it this is the ss of my visual designer:



the outer pink panel is the panelana which i scale and the main activity screen consists buttons and menus. Some action is going on on the panelana ( the pink one ) so when the user click on zoom out :

B4X:
ScalePanel(panelana,0.55)

nearly all the pink panel : panelana is fitted into activity.

My problem is when i change the scale , I cant find out the correct left,top values of the pink panel which i scaled. For example i want to create a label in scaled panel between the left and right value of the activity , but because the scaled panel is scaled , everything is mixed. What is the correct way of doing this . ? I know , I described it bad but i hope you can understand .
 

tufanv

Expert
Licensed User
Longtime User
I have a game with a radar screen where you are the air traffic controller . Radar screen is the scaled panel. I had to make a large enviroenment for simulated aircraft where the player can zoom in and out to radar screen. When the radar screen is scaledout like in the code to 0.55 it is the most zommed out screen and player can see the aircraft from a longer distance. If I scale the whole layout , also buttons and other controls are scaled too but this way i can only scale the radar screen and others are remains same.
What is the purpose of this code? This is not the correct way to scale your layout.
 
Upvote 0
Top