I'm using the getX() and getY() method on a view for some special dragging logic (not animation, i.e. I never use setX/Y methods, I just need the getters to check).
However, I've come to realize that these are only available post-API 11.
The docs for getX() say that is it the addition of the 'left' property and the 'translationX' property. All well and good, except get/setTranslationX() is only around since API 11 as well.
I was wondering if there was any knowledge on what this method returns behind the scenes, so I could maybe put in a workaround.
Use nineOldAndroid.jar
file in your project And use this way
import com.nineoldandroids.view.ViewHelper;
ViewHelper.setTranslationX(myView, translation);
ViewHelper.getX(myView);
How about getLeft() and getTop(). Looks to me like these are valid as long as the view hasn't been translated (setTranslationX() and setTranslationY()) which also aren't valid in the older API.
Using android.support.v4.view.ViewCompat
the solution is:
ViewCompat.getY(mView);
which is compatible with old android devices.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With