Android Question View position differs when set in code and Designer

Startup

Active Member
Licensed User
Longtime User
I set a view (button) position in Designer. but then when I try to match the position in code in the IDE using the same numbers with "dip" the position is slightly (10 dip or so) to the left and up). I have the designer set to match connected device and have matched the "show title" (False) and full screen (true) in both the IDE and Designer. Why don't the positions match?
 

Startup

Active Member
Licensed User
Longtime User
Without seeing what you have done and how it's impossible to give a concrete advice.
Why don't you post a small project showing the problem so we can see what you have done and how !
Here is the zip file ("Tester"). By putting a break at the Sub SetButtonPosition the button loads from the designer. Then when you step into the sub you can see the button moves to the left and then up even tho the left and top positions in the code are the same as in the designer. Thanks for your help with this!
 

Attachments

  • Tester.zip
    7.5 KB · Views: 170
Upvote 0

rscheel

Well-Known Member
Licensed User
Longtime User
try now.

that's what you need to do?
 

Attachments

  • Tester2.zip
    359.4 KB · Views: 202
Upvote 0

Startup

Active Member
Licensed User
Longtime User
try now.

that's what you need to do?
Thanks but I am trying to match the designer view position with code. I am developing an App which uses Animation and want to have the final position using Event:AnimationEnd with code to have a view positioned on top of a view created in Designer so I want to be able to match the left and top position in Designer with code. The zip file I posted demonstrates that using the same left and top position in code results in a different position from that created in designer.
 
Upvote 0

rscheel

Well-Known Member
Licensed User
Longtime User
then used the property to align left or right.

At least I played with all of these designer properties achieved, align on different devices in the same way.
 
Upvote 0

Startup

Active Member
Licensed User
Longtime User
On what kind of device are you using it ?
In the DesignerScripts in your project you have AutoScaleAll active.
If your device has a screen different from 320 * 480 / 160 the original positions are different.

The device is a Samsung Note 3 phone 1080 x 1920 pixels (~386 ppi pixel density). Are you saying I should make changes/code in DesignerScripts?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Are you saying I should make changes/code in DesignerScripts?
I don't know what exactly you want to do.
You have a layout for a screen of 320 x 480 / 160 and a device with 1080 x 1920 and AutoScaleAll.
As the dimensions and the height/width ratio between the reference screen (layout) and the device screen are different AutoScaleAll with scale the button therefore the positions are no more the same.
If you really want the same dimensions you should uncomment AutoScaleAll in the DesignerScripts.
 
Upvote 0

Startup

Active Member
Licensed User
Longtime User
What I want to do is use the Designer to find the left and top coordinates for a position which I want an animated label to end up at using Event:AnimationEnd. When I comment (I think you meant to say comment not uncomment) AutoScaleAll the coded position now matches the designer position in the demo zip file I posted. So that works. Thanks!
 
Upvote 0
Top