public static int getAbsoluteGravity(int gravity, int layoutDirection) {
        if (SDK_INT >= 17) {
            return Gravity.getAbsoluteGravity(gravity, layoutDirection);
        } else {
            // Just strip off the relative bit to get LEFT/RIGHT.
            return gravity & ~RELATIVE_LAYOUT_DIRECTION;
        }
    }
<p>Convert script specific gravity to absolute horizontal value.</p>
<p>
if horizontal direction is LTR, then START will set LEFT and END will set RIGHT.
if horizontal direction is RTL, then START will set RIGHT and END will set LEFT.

@param gravity         The gravity to convert to absolute (horizontal) values.
@param layoutDirection The layout direction.
@return gravity converted to absolute (horizontal) values.
android/android_framework/base/src/main/java/github/tornaco/android/thanos/core/compat/GravityCompat.java