Example usage for android.view Gravity NO_GRAVITY

List of usage examples for android.view Gravity NO_GRAVITY

Introduction

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

Prototype

int NO_GRAVITY

To view the source code for android.view Gravity NO_GRAVITY.

Click Source Link

Document

Constant indicating that no gravity has been set

Usage

From source file:android.car.ui.provider.CarDrawerLayout.java

@Override
protected void onRestoreInstanceState(Parcelable state) {
    SavedState ss = null;/*from w w w .  j  av a 2 s.  c  o m*/
    if (state.getClass().getClassLoader() != getClass().getClassLoader()) {
        // Class loader mismatch, recreate from parcel.
        Parcel stateParcel = Parcel.obtain();
        state.writeToParcel(stateParcel, 0);
        ss = SavedState.CREATOR.createFromParcel(stateParcel);
    } else {
        ss = (SavedState) state;
    }
    super.onRestoreInstanceState(ss.getSuperState());

    if (ss.openDrawerGravity != Gravity.NO_GRAVITY) {
        openDrawer();
    }

    setDrawerLockMode(ss.lockModeLeft, Gravity.LEFT);
    setDrawerLockMode(ss.lockModeRight, Gravity.RIGHT);
}

From source file:com.aidy.bottomdrawerlayout.BottomDrawerLayout.java

@Override
protected void onRestoreInstanceState(Parcelable state) {
    final SavedState ss = (SavedState) state;
    super.onRestoreInstanceState(ss.getSuperState());

    if (ss.openDrawerGravity != Gravity.NO_GRAVITY) {
        final View toOpen = findDrawerWithGravity(ss.openDrawerGravity);
        if (toOpen != null) {
            openDrawer(toOpen);/*w ww .  ja v a  2s  . c o  m*/
        }
    }
    setDrawerLockMode(ss.lockModeBottom, Gravity.BOTTOM);
}

From source file:com.actionbarsherlock.custom.widget.VerticalDrawerLayout.java

@Override
protected void onRestoreInstanceState(Parcelable state) {
    final SavedState ss = (SavedState) state;
    super.onRestoreInstanceState(ss.getSuperState());

    if (ss.openDrawerGravity != Gravity.NO_GRAVITY) {
        final View toOpen = findDrawerWithGravity(ss.openDrawerGravity);
        if (toOpen != null) {
            openDrawer(toOpen);//  w w w  .  j ava 2s . co  m
        }
    }

    setDrawerLockMode(ss.lockModeTop, Gravity.TOP);
    setDrawerLockMode(ss.lockModeBottom, Gravity.BOTTOM);
}

From source file:com.quwu.xinwo.release.Release_Activity.java

/**
 * /*from   ww w  .  j  a v a  2 s . c om*/
 * PopupWindow
 * 
 * */
private void showPopupWindow(View view, final int i) {

    // 
    View contentView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.release_pop, null);

    final PopupWindow popupWindow = new PopupWindow(contentView, LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT, true);
    popupWindow.setOnDismissListener(new OnDismissListener() {

        public void onDismiss() {
            releaseLin.setAlpha(1f);
        }
    });
    popupWindow.setTouchable(true);

    popupWindow.setTouchInterceptor(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {

            return false;
            // true?touch
            // ? PopupWindowonTouchEvent?dismiss
        }
    });

    // ?PopupWindowBackdismiss
    // APIbug
    popupWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.ic_launcher));

    // ???show
    int[] location = new int[2];
    view.getLocationOnScreen(location);

    popupWindow.showAtLocation(view, Gravity.NO_GRAVITY, location[0] + view.getWidth(), location[1] - 150);

    // 
    TextView year = (TextView) contentView.findViewById(R.id.release_pop_yearText);
    year.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            handler.sendMessage(handler.obtainMessage(i, "/"));
            popupWindow.dismiss();
        }
    });
    TextView month = (TextView) contentView.findViewById(R.id.release_pop_monthText);
    month.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            handler.sendMessage(handler.obtainMessage(i, "/"));
            popupWindow.dismiss();
        }
    });
    TextView day = (TextView) contentView.findViewById(R.id.release_pop_dayText);
    day.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            handler.sendMessage(handler.obtainMessage(i, "/"));
            popupWindow.dismiss();
        }
    });
}

From source file:android.support.design.widget.CoordinatorLayout.java

/**
 * Return the given gravity value, but if either or both of the axes doesn't have any gravity
 * specified, the default value (start or top) is specified. This should be used for children
 * that are not anchored to another view or a keyline.
 *///from   w ww . jav  a 2 s  .c om
private static int resolveGravity(int gravity) {
    if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.NO_GRAVITY) {
        gravity |= GravityCompat.START;
    }
    if ((gravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.NO_GRAVITY) {
        gravity |= Gravity.TOP;
    }
    return gravity;
}

From source file:android.support.design.widget.CoordinatorLayout.java

/**
 * Return the given gravity value or the default if the passed value is NO_GRAVITY.
 * This should be used for children that are positioned relative to a keyline.
 *//* ww  w. ja va 2  s  . c o m*/
private static int resolveKeylineGravity(int gravity) {
    return gravity == Gravity.NO_GRAVITY ? GravityCompat.END | Gravity.TOP : gravity;
}

From source file:radialdemo.RadialMenuWidget.java

/**
 * Shows the radial menu widget.//from ww  w .ja  va  2s  .co m
 * @param anchor - View to be anchored to.
 * @param posX - Position X. Pass 0 if not needed.
 * @param posY - Position Y. Pass 0 if not needed.
 */
public void show(View anchor, int posX, int posY) {
    mWindow.setContentView(this);
    mWindow.showAtLocation(anchor, Gravity.NO_GRAVITY, posX, posY);
}

From source file:android.support.design.widget.CoordinatorLayout.java

/**
 * Return the given gravity value or the default if the passed value is NO_GRAVITY.
 * This should be used for children that are anchored to another view.
 *///from w  w  w .  j  a v a2  s. c  o m
private static int resolveAnchoredChildGravity(int gravity) {
    return gravity == Gravity.NO_GRAVITY ? Gravity.CENTER : gravity;
}

From source file:radialdemo.RadialMenuWidget.java

/**
 * Shows the radial menu widget./*from w w w .j  a  va2s . c  om*/
 * @param anchor - View to be anchored to.
 */
public void show(View anchor) {
    mWindow.setContentView(this);
    mWindow.showAtLocation(anchor, Gravity.NO_GRAVITY, this.xSource, this.ySource);
}

From source file:com.huyn.demogroup.bahavior.widget.CoordinatorLayout.java

/**
 * Dispatch any dependent view changes to the relevant {@link Behavior} instances.
 *
 * Usually run as part of the pre-draw step when at least one child view has a reported
 * dependency on another view. This allows CoordinatorLayout to account for layout
 * changes and animations that occur outside of the normal layout pass.
 *
 * It can also be ran as part of the nested scrolling dispatch to ensure that any offsetting
 * is completed within the correct coordinate window.
 *
 * The offsetting behavior implemented here does not store the computed offset in
 * the LayoutParams; instead it expects that the layout process will always reconstruct
 * the proper positioning.// w w w  . j  ava  2 s.  co m
 *
 * @param type the type of event which has caused this call
 */
final void onChildViewsChanged(@DispatchChangeEvent final int type) {
    final int layoutDirection = ViewCompat.getLayoutDirection(this);
    final int childCount = mDependencySortedChildren.size();
    final Rect inset = mTempRect4;
    inset.setEmpty();
    for (int i = 0; i < childCount; i++) {
        final View child = mDependencySortedChildren.get(i);
        final LayoutParams lp = (LayoutParams) child.getLayoutParams();

        // Check child views before for anchor
        for (int j = 0; j < i; j++) {
            final View checkChild = mDependencySortedChildren.get(j);

            if (lp.mAnchorDirectChild == checkChild) {
                offsetChildToAnchor(child, layoutDirection);
            }
        }

        // Get the current draw rect of the view
        final Rect drawRect = mTempRect1;
        getChildRect(child, true, drawRect);

        // Accumulate inset sizes
        if (lp.insetEdge != Gravity.NO_GRAVITY && !drawRect.isEmpty()) {
            final int absInsetEdge = GravityCompat.getAbsoluteGravity(lp.insetEdge, layoutDirection);
            switch (absInsetEdge & Gravity.VERTICAL_GRAVITY_MASK) {
            case Gravity.TOP:
                inset.top = Math.max(inset.top, drawRect.bottom);
                break;
            case Gravity.BOTTOM:
                inset.bottom = Math.max(inset.bottom, getHeight() - drawRect.top);
                break;
            }
            switch (absInsetEdge & Gravity.HORIZONTAL_GRAVITY_MASK) {
            case Gravity.LEFT:
                inset.left = Math.max(inset.left, drawRect.right);
                break;
            case Gravity.RIGHT:
                inset.right = Math.max(inset.right, getWidth() - drawRect.left);
                break;
            }
        }

        // Dodge inset edges if necessary
        if (lp.dodgeInsetEdges != Gravity.NO_GRAVITY && child.getVisibility() == View.VISIBLE) {
            offsetChildByInset(child, inset, layoutDirection);
        }

        if (type == EVENT_PRE_DRAW) {
            // Did it change? if not continue
            final Rect lastDrawRect = mTempRect2;
            getLastChildRect(child, lastDrawRect);
            if (lastDrawRect.equals(drawRect)) {
                continue;
            }
            recordLastChildRect(child, drawRect);
        }

        // Update any behavior-dependent views for the change
        for (int j = i + 1; j < childCount; j++) {
            final View checkChild = mDependencySortedChildren.get(j);
            final LayoutParams checkLp = (LayoutParams) checkChild.getLayoutParams();
            final Behavior b = checkLp.getBehavior();

            if (b != null && b.layoutDependsOn(this, checkChild, child)) {
                if (type == EVENT_PRE_DRAW && checkLp.getChangedAfterNestedScroll()) {
                    // If this is from a pre-draw and we have already been changed
                    // from a nested scroll, skip the dispatch and reset the flag
                    checkLp.resetChangedAfterNestedScroll();
                    continue;
                }

                final boolean handled;
                switch (type) {
                case EVENT_VIEW_REMOVED:
                    // EVENT_VIEW_REMOVED means that we need to dispatch
                    // onDependentViewRemoved() instead
                    b.onDependentViewRemoved(this, checkChild, child);
                    handled = true;
                    break;
                default:
                    // Otherwise we dispatch onDependentViewChanged()
                    handled = b.onDependentViewChanged(this, checkChild, child);
                    break;
                }

                if (type == EVENT_NESTED_SCROLL) {
                    // If this is from a nested scroll, set the flag so that we may skip
                    // any resulting onPreDraw dispatch (if needed)
                    checkLp.setChangedAfterNestedScroll(handled);
                }
            }
        }
    }
}