Example usage for android.view Gravity isHorizontal

List of usage examples for android.view Gravity isHorizontal

Introduction

In this page you can find the example usage for android.view Gravity isHorizontal.

Prototype

public static boolean isHorizontal(int gravity) 

Source Link

Document

Indicate whether the supplied gravity has an horizontal pull.

Usage

From source file:com.andremion.floatingnavigationview.FloatingNavigationView.java

private void attachNavigationView() {

    CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) getLayoutParams();
    int gravity = Gravity.LEFT;
    if (layoutParams.getAnchorId() != View.NO_ID && layoutParams.anchorGravity != Gravity.NO_GRAVITY) {
        if (Gravity.isHorizontal(layoutParams.anchorGravity)) {
            gravity = layoutParams.anchorGravity;
        }/*from  w  ww .  j a v a 2  s .c  o  m*/
    } else if (layoutParams.gravity != Gravity.NO_GRAVITY) {
        if (Gravity.isHorizontal(layoutParams.gravity)) {
            gravity = layoutParams.gravity;
        }
    }

    // Gravity.START and Gravity.END don't work for views added in WindowManager with RTL.
    // We need to convert script specific gravity to absolute horizontal value
    // 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.
    gravity = Gravity.getAbsoluteGravity(gravity, getLayoutDirection());

    mWindowManager.addView(mNavigationView, createLayoutParams(gravity));
}