What does offsetLeftAndRight() exactly do?

2019-04-22 17:39发布

问题:

What does offsetLeftAndRight() exactly do? Documentation says: "Offset this view's horizontal location by the specified amount of pixels" So, does it mean that if the view's left position is suppose 50 and offsetLeftAndRight(20) is called on it, then the view will move by 20pixels & its left position will be (50-20) i.e. 30?

Thanks in advance.

回答1:

Both the left and the right positions will be incremented by the offset. So in your example, the left position will change to 50 + 20 = 70.