Forum Xamarin Cross Platform with Xamarin

Using margin or translation

sastsast NLMember
edited February 2017 in Cross Platform with Xamarin

What is the difference between margin and translation? Example:

<Label TranslationY="10" Text="Test" />
<Label Margin="0,10,0,0" Text="Test" />

For me the result is the same, both labels have a top-outerspace of 10. I tested both labels in a ViewCell, looks like Translation is faster (saving a layout update?). Are there disadvantages for choosing Translation?


Best Answer


  • sastsast NLMember

    @ClintStLaurent thank you for answering! Clear enough! I misunderstood the difference in relative positioning. For me TranslationY suffice, because the height of the (parent) element is fixed.

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭
    edited February 2017

    I would suggest going the other way. Use Margin by default. That's the standard everyone follows and results in the least amount of "WTF is happening with my layout?"

    Use Translate when you have a specific reason to need post-layout re-positioning.

Sign In or Register to comment.