I have a problem with Designer Left position

enonod

Well-Known Member
Licensed User
Longtime User
I have a Panel on the Activity and its Left is set to 2
On the Panel I have a ToggleButton whose Left is set to zero
The buttons parent was set to the Panel automatically.
Moving the button shows it is a child because it will not move off the Panel.

The buttons Left when run on the emulator is two pixels right from the Panel edge.
Setting the button Left to -2 does solve it.

If I set the Panel Left to zero the button appears 2 pixels right of the edge.

In addition I also note that if I draw a rectangle on the Activity, at y=zero x=zero the left line shows but the top line is (presumably) under the grey box showing the word Activity and so x+1 cures it.

Is this something that has to be worked around or more likely is there something that I have failed to understand please?
 

klaus

Expert
Licensed User
Longtime User
The default Togglebutton image has a transparent border of some pixels like the standard buttons.

I experiment also the problem with the missing line on top of the screen on the Emulator, but on my Nexus One it is displayed.

Best regards.
 
Upvote 0

enonod

Well-Known Member
Licensed User
Longtime User
It seems odd then that the top edge of the button touches the top edge of the label correctly and reads as zero. The right and bottom are more difficult to check because we only have relative figures. So it appears to be not a border but Left only.
So I guess a workaround has to be used.

Perhaps you know the reason for these extra invisible pixels?
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
If you change the background color:

ToggleButton1.Color=Colors.Red

I think it may fill the space so you can compare it to the standard togglebutton.

It may help
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Perhaps you know the reason for these extra invisible pixels?
No, I suppose that's how the Android designers wanted it.

If you want the full space filled, have a look here.

Best regards.
 
Last edited:
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Hi Klaus,

Your link doesn't go anywhere.
 
Upvote 0

enonod

Well-Known Member
Licensed User
Longtime User
Thank you for that suggestion.
Very illuminating!!
The left edge AND bottom (when red) have extra pixels, no change elsewhere.
I am impressed but none the wiser as to why, nor do I know to which views it applies without doing tests on each.
Without a reason this seems very odd to me.
[EDIT]We crossed in the post and correct the link goes nowhere.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
That's strange, on my test, the right edge appears to have the same spacing as the left. I would think it's a design thing so there is automatically space between the objects without having to line them up manually.

As can be seen when changing the background colour, its the images the togglebutton displays and not the togglebutton size that contains the space.
 
Upvote 0

enonod

Well-Known Member
Licensed User
Longtime User
I think you are right that it is to do with the bitmap image not being the same size as the button, or containing rectangle.
In my view most such matters are not pre-designed in that manner unless there is a good reason, better to leave it to the programmer to decide if they wish the buttons to touch each other or leave a gap.
There must be a reason for this image being smaller or there is something wrong.
It is still odd that zero left and zero top do not place the 'image' two pixels in and down, only in from left (on the emulator).
I have not tried any other views.
Maybe somebody can give a definitive reason for this behaviour then we can know the rules by which views can be placed and not have to guess.
 
Last edited:
Upvote 0
Top