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:io.github.hidroh.materialistic.widget.FavoriteRecyclerViewAdapter.java

private void showMoreOptions(View v, final Favorite item) {
    mPopupMenu.create(mContext, v, Gravity.NO_GRAVITY).inflate(R.menu.menu_contextual_favorite)
            .setOnMenuItemClickListener(menuItem -> {
                if (menuItem.getItemId() == R.id.menu_contextual_vote) {
                    vote(item);// w  w  w.  ja  va 2  s  .co  m
                    return true;
                }
                if (menuItem.getItemId() == R.id.menu_contextual_comment) {
                    mContext.startActivity(new Intent(mContext, ComposeActivity.class)
                            .putExtra(ComposeActivity.EXTRA_PARENT_ID, item.getId())
                            .putExtra(ComposeActivity.EXTRA_PARENT_TEXT, item.getDisplayedTitle()));
                    return true;
                }
                if (menuItem.getItemId() == R.id.menu_contextual_share) {
                    mContext.startActivity(
                            AppUtils.makeChooserShareIntent(mContext, item.getDisplayedTitle(), item.getUrl()));
                    return true;
                }
                return false;
            }).show();
}

From source file:ca.mymenuapp.ui.widgets.SlidingUpPanelLayout.java

public SlidingUpPanelLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (attrs != null) {
        TypedArray defAttrs = context.obtainStyledAttributes(attrs, DEFAULT_ATTRS);

        if (defAttrs != null) {
            int gravity = defAttrs.getInt(0, Gravity.NO_GRAVITY);
            if (gravity != Gravity.TOP && gravity != Gravity.BOTTOM) {
                throw new IllegalArgumentException("layout_gravity must be set to either top or bottom");
            }//from   www.ja  va2 s. c  o m
            mIsSlidingUp = gravity == Gravity.BOTTOM;
        }

        defAttrs.recycle();

        TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidingUpPanelLayout);

        if (ta != null) {
            mPanelHeight = ta.getDimensionPixelSize(R.styleable.SlidingUpPanelLayout_collapsedHeight, -1);
            mShadowHeight = ta.getDimensionPixelSize(R.styleable.SlidingUpPanelLayout_shadowHeight, -1);

            mMinFlingVelocity = ta.getInt(R.styleable.SlidingUpPanelLayout_flingVelocity,
                    DEFAULT_MIN_FLING_VELOCITY);
            mCoveredFadeColor = ta.getColor(R.styleable.SlidingUpPanelLayout_fadeColor, DEFAULT_FADE_COLOR);

            mDragViewResId = ta.getResourceId(R.styleable.SlidingUpPanelLayout_dragView, -1);
        }

        ta.recycle();
    }

    final float density = context.getResources().getDisplayMetrics().density;
    if (mPanelHeight == -1) {
        mPanelHeight = (int) (DEFAULT_PANEL_HEIGHT * density + 0.5f);
    }
    if (mShadowHeight == -1) {
        mShadowHeight = (int) (DEFAULT_SHADOW_HEIGHT * density + 0.5f);
    }

    setWillNotDraw(false);

    mDragHelper = ViewDragHelper.create(this, 0.5f, new DragHelperCallback());
    mDragHelper.setMinVelocity(mMinFlingVelocity * density);

    mCanSlide = true;
    mIsSlidingEnabled = true;

    ViewConfiguration vc = ViewConfiguration.get(context);
    mScrollTouchSlop = vc.getScaledTouchSlop();
}

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 ww  w  . j av  a2s.  c  om
    } 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));
}

From source file:org.loon.framework.android.game.LGameAndroid2DActivity.java

public void initialization(final boolean landscape, final boolean openAD, final Location lad,
        final String publisherId, final String keywords, final int requestInterval) {
    if (openAD) {
        // setVolumeControlStream(AudioManager.STREAM_MUSIC);
        AdManager.setPublisherId(publisherId);
        AdManager.setTestDevices(new String[] { "" });
        AdManager.setAllowUseOfLocation(true);
        view = new LGameAndroid2DView(LGameAndroid2DActivity.this, landscape);
        IHandler handler = view.getGameHandler();
        RelativeLayout mainLayout = new RelativeLayout(LGameAndroid2DActivity.this);
        RelativeLayout.LayoutParams mainParams = new RelativeLayout.LayoutParams(handler.getWidth(),
                handler.getHeight());//from   www  .j  ava2s .c om
        if (landscape) {
            mainParams.addRule(RelativeLayout.CENTER_HORIZONTAL, 1);
        } else {
            mainParams.addRule(RelativeLayout.CENTER_IN_PARENT, 1);
        }
        mainLayout.addView(view, mainParams);

        adview = new AdView(LGameAndroid2DActivity.this);
        if (keywords != null) {
            adview.setKeywords(keywords);
        }
        adview.setRequestInterval(requestInterval);
        adview.setGravity(Gravity.NO_GRAVITY);
        RelativeLayout rl = new RelativeLayout(LGameAndroid2DActivity.this);
        RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
                LayoutParams.WRAP_CONTENT);
        if (lad == Location.LEFT) {
            lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 1);
        } else if (lad == Location.RIGHT) {
            lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 1);
        } else if (lad == Location.TOP) {
            lp.addRule(RelativeLayout.ALIGN_PARENT_TOP, 1);
        } else {
            lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 1);
        }
        // adview.setVisibility(View.GONE);

        visible = true;
        frameLayout.addView(mainLayout);
        rl.addView(adview, lp);
        frameLayout.addView(rl);
    } else {
        view = new LGameAndroid2DView(LGameAndroid2DActivity.this, landscape);
        IHandler handler = view.getGameHandler();
        RelativeLayout mainLayout = new RelativeLayout(LGameAndroid2DActivity.this);
        RelativeLayout.LayoutParams mainParams = new RelativeLayout.LayoutParams(handler.getWidth(),
                handler.getHeight());
        if (landscape) {
            mainParams.addRule(RelativeLayout.CENTER_HORIZONTAL, 1);
        } else {
            mainParams.addRule(RelativeLayout.CENTER_IN_PARENT, 1);
        }
        mainLayout.addView(view, mainParams);
        frameLayout.addView(mainLayout);
    }
    if (setupSensors) {
        // ??
        this.initSensors();
    }
    if (view != null) {
        gameHandler = view.getGameHandler();
    }
}

From source file:com.facebook.react.flat.RCTText.java

public Layout.Alignment getAlignment() {
    boolean isRtl = getLayoutDirection() == YogaDirection.RTL;
    switch (mAlignment) {
    // Layout.Alignment.RIGHT and Layout.Alignment.LEFT are @hide :(
    case Gravity.LEFT:
        int index = isRtl ? ALIGNMENT_RIGHT : ALIGNMENT_LEFT;
        return Layout.Alignment.values()[index];
    case Gravity.RIGHT:
        index = isRtl ? ALIGNMENT_LEFT : ALIGNMENT_RIGHT;
        return Layout.Alignment.values()[index];
    case Gravity.CENTER:
        return Layout.Alignment.ALIGN_CENTER;
    case Gravity.NO_GRAVITY:
    default://from   w ww.j ava 2s .  c om
        return Layout.Alignment.ALIGN_NORMAL;
    }
}

From source file:android.support.wear.widget.drawer.WearableDrawerView.java

int preferGravity() {
    return Gravity.NO_GRAVITY;
}

From source file:kz.qobyzbook.slidinguppanelhelper.SlidingUpPanelLayout.java

public SlidingUpPanelLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    if (isInEditMode()) {
        mShadowDrawable = null;/*from   ww w. j a v  a  2s . c  o m*/
        mDragHelper = null;
        return;
    }

    if (attrs != null) {
        TypedArray defAttrs = context.obtainStyledAttributes(attrs, DEFAULT_ATTRS);

        if (defAttrs != null) {
            int gravity = defAttrs.getInt(0, Gravity.NO_GRAVITY);
            setGravity(gravity);
        }

        defAttrs.recycle();

        TypedArray ta = context.obtainStyledAttributes(attrs, kz.qobyzbook.R.styleable.SlidingUpPanelLayout);

        if (ta != null) {
            mPanelHeight = ta
                    .getDimensionPixelSize(kz.qobyzbook.R.styleable.SlidingUpPanelLayout_umanoPanelHeight, -1);
            mShadowHeight = ta
                    .getDimensionPixelSize(kz.qobyzbook.R.styleable.SlidingUpPanelLayout_umanoShadowHeight, -1);
            mParallaxOffset = ta.getDimensionPixelSize(
                    kz.qobyzbook.R.styleable.SlidingUpPanelLayout_umanoParalaxOffset, -1);

            mMinFlingVelocity = ta.getInt(kz.qobyzbook.R.styleable.SlidingUpPanelLayout_umanoFlingVelocity,
                    DEFAULT_MIN_FLING_VELOCITY);
            mCoveredFadeColor = ta.getColor(kz.qobyzbook.R.styleable.SlidingUpPanelLayout_umanoFadeColor,
                    DEFAULT_FADE_COLOR);

            mDragViewResId = ta.getResourceId(kz.qobyzbook.R.styleable.SlidingUpPanelLayout_umanoDragView, -1);

            mOverlayContent = ta.getBoolean(kz.qobyzbook.R.styleable.SlidingUpPanelLayout_umanoOverlay,
                    DEFAULT_OVERLAY_FLAG);
            mClipPanel = ta.getBoolean(kz.qobyzbook.R.styleable.SlidingUpPanelLayout_umanoClipPanel,
                    DEFAULT_CLIP_PANEL_FLAG);

            mAnchorPoint = ta.getFloat(kz.qobyzbook.R.styleable.SlidingUpPanelLayout_umanoAnchorPoint,
                    DEFAULT_ANCHOR_POINT);

            mSlideState = PanelState.values()[ta.getInt(
                    kz.qobyzbook.R.styleable.SlidingUpPanelLayout_umanoInitialState,
                    DEFAULT_SLIDE_STATE.ordinal())];
        }

        ta.recycle();
    }

    final float density = context.getResources().getDisplayMetrics().density;
    if (mPanelHeight == -1) {
        mPanelHeight = (int) (DEFAULT_PANEL_HEIGHT * density + 0.5f);
    }
    if (mShadowHeight == -1) {
        mShadowHeight = (int) (DEFAULT_SHADOW_HEIGHT * density + 0.5f);
    }
    if (mParallaxOffset == -1) {
        mParallaxOffset = (int) (DEFAULT_PARALAX_OFFSET * density);
    }
    // If the shadow height is zero, don't show the shadow
    if (mShadowHeight > 0) {
        if (mIsSlidingUp) {
            mShadowDrawable = getResources().getDrawable(kz.qobyzbook.R.drawable.above_shadow);
        } else {
            mShadowDrawable = getResources().getDrawable(kz.qobyzbook.R.drawable.below_shadow);
        }

    } else {
        mShadowDrawable = null;
    }

    setWillNotDraw(false);

    mDragHelper = ViewDragHelper.create(this, 0.5f, new DragHelperCallback());
    mDragHelper.setMinVelocity(mMinFlingVelocity * density);

    mIsTouchEnabled = true;
}

From source file:com.akshay.protocol10.asplayer.widget.SlidingUpPanelLayout.java

public SlidingUpPanelLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    if (isInEditMode()) {
        mShadowDrawable = null;/* w ww. jav  a 2s.  co m*/
        mDragHelper = null;
        return;
    }

    if (attrs != null) {
        TypedArray defAttrs = context.obtainStyledAttributes(attrs, DEFAULT_ATTRS);

        if (defAttrs != null) {
            int gravity = defAttrs.getInt(0, Gravity.NO_GRAVITY);
            if (gravity != Gravity.TOP && gravity != Gravity.BOTTOM) {
                throw new IllegalArgumentException("gravity must be set to either top or bottom");
            }
            mIsSlidingUp = gravity == Gravity.BOTTOM;
        }

        defAttrs.recycle();

        TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidingUpPanelLayout);

        if (ta != null) {
            mPanelHeight = ta.getDimensionPixelSize(R.styleable.SlidingUpPanelLayout_panelHeight, -1);
            mShadowHeight = ta.getDimensionPixelSize(R.styleable.SlidingUpPanelLayout_shadowHeight, -1);
            mParallaxOffset = ta.getDimensionPixelSize(R.styleable.SlidingUpPanelLayout_paralaxOffset, -1);

            mMinFlingVelocity = ta.getInt(R.styleable.SlidingUpPanelLayout_flingVelocity,
                    DEFAULT_MIN_FLING_VELOCITY);
            mCoveredFadeColor = ta.getColor(R.styleable.SlidingUpPanelLayout_fadeColor, DEFAULT_FADE_COLOR);

            mDragViewResId = ta.getResourceId(R.styleable.SlidingUpPanelLayout_dragView, -1);

            mOverlayContent = ta.getBoolean(R.styleable.SlidingUpPanelLayout_overlay, DEFAULT_OVERLAY_FLAG);

            mAnchorPoint = ta.getFloat(R.styleable.SlidingUpPanelLayout_anchorPoint, DEFAULT_ANCHOR_POINT);

            mSlideState = SlideState.values()[ta.getInt(R.styleable.SlidingUpPanelLayout_initialState,
                    DEFAULT_SLIDE_STATE.ordinal())];
        }

        ta.recycle();
    }

    final float density = context.getResources().getDisplayMetrics().density;
    if (mPanelHeight == -1) {
        mPanelHeight = (int) (DEFAULT_PANEL_HEIGHT * density + 0.5f);
    }
    if (mShadowHeight == -1) {
        mShadowHeight = (int) (DEFAULT_SHADOW_HEIGHT * density + 0.5f);
    }
    if (mParallaxOffset == -1) {
        mParallaxOffset = (int) (DEFAULT_PARALAX_OFFSET * density);
    }
    // If the shadow height is zero, don't show the shadow
    if (mShadowHeight > 0) {
        if (mIsSlidingUp) {
            mShadowDrawable = getResources().getDrawable(R.drawable.above_shadow);
        } else {
            mShadowDrawable = getResources().getDrawable(R.drawable.below_shadow);
        }

    } else {
        mShadowDrawable = null;
    }

    setWillNotDraw(false);

    mDragHelper = ViewDragHelper.create(this, 0.5f, new DragHelperCallback());
    mDragHelper.setMinVelocity(mMinFlingVelocity * density);

    mIsSlidingEnabled = true;
}

From source file:co.codecrunch.musicplayerlite.slidinguppanelhelper.SlidingUpPanelLayout.java

public SlidingUpPanelLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    if (isInEditMode()) {
        mShadowDrawable = null;/*from w w  w .  j a v  a 2  s. c o  m*/
        mDragHelper = null;
        return;
    }

    if (attrs != null) {
        TypedArray defAttrs = context.obtainStyledAttributes(attrs, DEFAULT_ATTRS);

        if (defAttrs != null) {
            int gravity = defAttrs.getInt(0, Gravity.NO_GRAVITY);
            setGravity(gravity);
        }

        defAttrs.recycle();

        TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidingUpPanelLayout);

        if (ta != null) {
            mPanelHeight = ta.getDimensionPixelSize(R.styleable.SlidingUpPanelLayout_umanoPanelHeight, -1);
            mShadowHeight = ta.getDimensionPixelSize(R.styleable.SlidingUpPanelLayout_umanoShadowHeight, -1);
            mParallaxOffset = ta.getDimensionPixelSize(R.styleable.SlidingUpPanelLayout_umanoParalaxOffset, -1);

            mMinFlingVelocity = ta.getInt(R.styleable.SlidingUpPanelLayout_umanoFlingVelocity,
                    DEFAULT_MIN_FLING_VELOCITY);
            mCoveredFadeColor = ta.getColor(R.styleable.SlidingUpPanelLayout_umanoFadeColor,
                    DEFAULT_FADE_COLOR);

            mDragViewResId = ta.getResourceId(R.styleable.SlidingUpPanelLayout_umanoDragView, -1);

            mOverlayContent = ta.getBoolean(R.styleable.SlidingUpPanelLayout_umanoOverlay,
                    DEFAULT_OVERLAY_FLAG);
            mClipPanel = ta.getBoolean(R.styleable.SlidingUpPanelLayout_umanoClipPanel,
                    DEFAULT_CLIP_PANEL_FLAG);

            mAnchorPoint = ta.getFloat(R.styleable.SlidingUpPanelLayout_umanoAnchorPoint, DEFAULT_ANCHOR_POINT);

            mSlideState = PanelState.values()[ta.getInt(R.styleable.SlidingUpPanelLayout_umanoInitialState,
                    DEFAULT_SLIDE_STATE.ordinal())];
        }

        ta.recycle();
    }

    final float density = context.getResources().getDisplayMetrics().density;
    if (mPanelHeight == -1) {
        mPanelHeight = (int) (DEFAULT_PANEL_HEIGHT * density + 0.5f);
    }
    if (mShadowHeight == -1) {
        mShadowHeight = (int) (DEFAULT_SHADOW_HEIGHT * density + 0.5f);
    }
    if (mParallaxOffset == -1) {
        mParallaxOffset = (int) (DEFAULT_PARALAX_OFFSET * density);
    }
    // If the shadow height is zero, don't show the shadow
    if (mShadowHeight > 0) {
        if (mIsSlidingUp) {
            mShadowDrawable = getResources().getDrawable(R.drawable.above_shadow);
        } else {
            mShadowDrawable = getResources().getDrawable(R.drawable.below_shadow);
        }

    } else {
        mShadowDrawable = null;
    }

    setWillNotDraw(false);

    mDragHelper = ViewDragHelper.create(this, 0.5f, new DragHelperCallback());
    mDragHelper.setMinVelocity(mMinFlingVelocity * density);

    mIsTouchEnabled = true;
}

From source file:mega.privacy.android.app.components.SlidingUpPanelLayout.java

public SlidingUpPanelLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    if (isInEditMode()) {
        mShadowDrawable = null;/* w  w w .  j  a v  a2s .c  o  m*/
        mDragHelper = null;
        return;
    }

    if (attrs != null) {
        TypedArray defAttrs = context.obtainStyledAttributes(attrs, DEFAULT_ATTRS);

        if (defAttrs != null) {
            int gravity = defAttrs.getInt(0, Gravity.NO_GRAVITY);
            setGravity(gravity);
        }

        defAttrs.recycle();

        TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidingUpPanelLayout);

        if (ta != null) {
            mPanelHeight = ta.getDimensionPixelSize(R.styleable.SlidingUpPanelLayout_umanoPanelHeight, -1);
            mShadowHeight = ta.getDimensionPixelSize(R.styleable.SlidingUpPanelLayout_umanoShadowHeight, -1);
            mParallaxOffset = ta.getDimensionPixelSize(R.styleable.SlidingUpPanelLayout_umanoParallaxOffset,
                    -1);

            mMinFlingVelocity = ta.getInt(R.styleable.SlidingUpPanelLayout_umanoFlingVelocity,
                    DEFAULT_MIN_FLING_VELOCITY);
            mCoveredFadeColor = ta.getColor(R.styleable.SlidingUpPanelLayout_umanoFadeColor,
                    DEFAULT_FADE_COLOR);

            mDragViewResId = ta.getResourceId(R.styleable.SlidingUpPanelLayout_umanoDragView, -1);

            mOverlayContent = ta.getBoolean(R.styleable.SlidingUpPanelLayout_umanoOverlay,
                    DEFAULT_OVERLAY_FLAG);
            mClipPanel = ta.getBoolean(R.styleable.SlidingUpPanelLayout_umanoClipPanel,
                    DEFAULT_CLIP_PANEL_FLAG);

            mAnchorPoint = ta.getFloat(R.styleable.SlidingUpPanelLayout_umanoAnchorPoint, DEFAULT_ANCHOR_POINT);

            mSlideState = PanelState.values()[ta.getInt(R.styleable.SlidingUpPanelLayout_umanoInitialState,
                    DEFAULT_SLIDE_STATE.ordinal())];
        }

        ta.recycle();
    }

    final float density = context.getResources().getDisplayMetrics().density;
    if (mPanelHeight == -1) {
        mPanelHeight = (int) (DEFAULT_PANEL_HEIGHT * density + 0.5f);
    }
    if (mShadowHeight == -1) {
        mShadowHeight = (int) (DEFAULT_SHADOW_HEIGHT * density + 0.5f);
    }
    if (mParallaxOffset == -1) {
        mParallaxOffset = (int) (DEFAULT_PARALAX_OFFSET * density);
    }
    // If the shadow height is zero, don't show the shadow
    if (mShadowHeight > 0) {
        if (mIsSlidingUp) {
            mShadowDrawable = getResources().getDrawable(R.drawable.above_shadow);
        } else {
            mShadowDrawable = getResources().getDrawable(R.drawable.below_shadow);
        }

    } else {
        mShadowDrawable = null;
    }

    setWillNotDraw(false);

    mDragHelper = ViewDragHelper.create(this, 0.5f, new DragHelperCallback());
    mDragHelper.setMinVelocity(mMinFlingVelocity * density);

    mIsTouchEnabled = true;
}