List of usage examples for android.support.v4.view GravityCompat getAbsoluteGravity
public static int getAbsoluteGravity(int i, int i2)
From source file:com.aidy.bottomdrawerlayout.BottomDrawerLayout.java
/** * Set a simple drawable used for the left or right shadow. The drawable * provided must have a nonzero intrinsic width. * //from w w w .j av a2 s. c o m * @param shadowDrawable * Shadow drawable to use at the edge of a drawer * @param gravity * Which drawer the shadow should apply to */ public void setDrawerShadow(Drawable shadowDrawable, int gravity) { final int absGravity = GravityCompat.getAbsoluteGravity(gravity, ViewCompat.getLayoutDirection(this)); if ((absGravity & Gravity.BOTTOM) == Gravity.BOTTOM) { mShadowBottom = shadowDrawable; invalidate(); } }
From source file:android.support.v7.view.menu.MenuPopupHelper.java
private void showPopup(int xOffset, int yOffset, boolean useOffsets, boolean showTitle) { final MenuPopup popup = getPopup(); popup.setShowTitle(showTitle);/* w w w . ja va2 s. c o m*/ if (useOffsets) { // If the resolved drop-down gravity is RIGHT, the popup's right // edge will be aligned with the anchor view. Adjust by the anchor // width such that the top-right corner is at the X offset. final int hgrav = GravityCompat.getAbsoluteGravity(mDropDownGravity, ViewCompat.getLayoutDirection(mAnchorView)) & Gravity.HORIZONTAL_GRAVITY_MASK; if (hgrav == Gravity.RIGHT) { xOffset -= mAnchorView.getWidth(); } popup.setHorizontalOffset(xOffset); popup.setVerticalOffset(yOffset); // Set the transition epicenter to be roughly finger (or mouse // cursor) sized and centered around the offset position. This // will give the appearance that the window is emerging from // the touch point. final float density = mContext.getResources().getDisplayMetrics().density; final int halfSize = (int) (TOUCH_EPICENTER_SIZE_DP * density / 2); final Rect epicenter = new Rect(xOffset - halfSize, yOffset - halfSize, xOffset + halfSize, yOffset + halfSize); popup.setEpicenterBounds(epicenter); } popup.show(); }
From source file:xyz.berial.textinputlayout.CollapsingTextHelper.java
private void calculateBaseOffsets() { // We then calculate the collapsed text size, using the same logic mTextPaint.setTextSize(mCollapsedTextSize); float width = mTextToDraw != null ? mTextPaint.measureText(mTextToDraw, 0, mTextToDraw.length()) : 0; final int collapsedAbsGravity = GravityCompat.getAbsoluteGravity(mCollapsedTextGravity, mIsRtl ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR); switch (collapsedAbsGravity & Gravity.VERTICAL_GRAVITY_MASK) { case Gravity.BOTTOM: mCollapsedDrawY = mCollapsedBounds.bottom; break;/*from www.j ava2 s .c o m*/ case Gravity.TOP: mCollapsedDrawY = mCollapsedBounds.top - mTextPaint.ascent(); break; case Gravity.CENTER_VERTICAL: default: float textHeight = mTextPaint.descent() - mTextPaint.ascent(); float textOffset = (textHeight / 2) - mTextPaint.descent(); mCollapsedDrawY = mCollapsedBounds.centerY() + textOffset; break; } switch (collapsedAbsGravity & Gravity.HORIZONTAL_GRAVITY_MASK) { case Gravity.CENTER_HORIZONTAL: mCollapsedDrawX = mCollapsedBounds.centerX() - (width / 2); break; case Gravity.RIGHT: mCollapsedDrawX = mCollapsedBounds.right - width; break; case Gravity.LEFT: default: mCollapsedDrawX = mCollapsedBounds.left; break; } mTextPaint.setTextSize(mExpandedTextSize); width = mTextToDraw != null ? mTextPaint.measureText(mTextToDraw, 0, mTextToDraw.length()) : 0; final int expandedAbsGravity = GravityCompat.getAbsoluteGravity(mExpandedTextGravity, mIsRtl ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR); switch (expandedAbsGravity & Gravity.VERTICAL_GRAVITY_MASK) { case Gravity.BOTTOM: mExpandedDrawY = mExpandedBounds.bottom; break; case Gravity.TOP: mExpandedDrawY = mExpandedBounds.top - mTextPaint.ascent(); break; case Gravity.CENTER_VERTICAL: default: float textHeight = mTextPaint.descent() - mTextPaint.ascent(); float textOffset = (textHeight / 2) - mTextPaint.descent(); mExpandedDrawY = mExpandedBounds.centerY() + textOffset; break; } switch (expandedAbsGravity & Gravity.HORIZONTAL_GRAVITY_MASK) { case Gravity.CENTER_HORIZONTAL: mExpandedDrawX = mExpandedBounds.centerX() - (width / 2); break; case Gravity.RIGHT: mExpandedDrawX = mExpandedBounds.right - width; break; case Gravity.LEFT: default: mExpandedDrawX = mExpandedBounds.left; break; } // The bounds have changed so we need to clear the texture clearTexture(); }
From source file:im.ene.lab.io_timer.ui.widget.MiniDrawerLayout.java
boolean isDrawerView(View child) { final int gravity = ((LayoutParams) child.getLayoutParams()).gravity; final int absGravity = GravityCompat.getAbsoluteGravity(gravity, ViewCompat.getLayoutDirection(child)); return (absGravity & (Gravity.RIGHT)) == Gravity.RIGHT; }
From source file:com.lansun.qmyo.view.DrawerLayout.java
/** * Set a simple drawable used for the left or right shadow. The drawable provided must have a nonzero intrinsic width. * //w ww . ja v a2 s .c o m * @param shadowDrawable * Shadow drawable to use at the edge of a drawer * @param gravity * Which drawer the shadow should apply to */ public void setDrawerShadow(Drawable shadowDrawable, int gravity) { /* * TODO Someone someday might want to set more complex drawables here. They're probably nuts, but we might want to consider registering callbacks, setting states, etc. properly. */ final int absGravity = GravityCompat.getAbsoluteGravity(gravity, ViewCompat.getLayoutDirection(this)); if ((absGravity & Gravity.LEFT) == Gravity.LEFT) { mShadowLeft = shadowDrawable; invalidate(); } if ((absGravity & Gravity.RIGHT) == Gravity.RIGHT) { mShadowRight = shadowDrawable; invalidate(); } }
From source file:com.actionbarsherlock.custom.widget.VerticalDrawerLayout.java
/** * Set a simple drawable used for the left or right shadow. * The drawable provided must have a nonzero intrinsic width. * * @param shadowDrawable Shadow drawable to use at the edge of a drawer * @param gravity Which drawer the shadow should apply to *///from w w w. ja va2 s .co m public void setDrawerShadow(Drawable shadowDrawable, int gravity) { /* * TODO Someone someday might want to set more complex drawables here. * They're probably nuts, but we might want to consider registering callbacks, * setting states, etc. properly. */ final int absGravity = GravityCompat.getAbsoluteGravity(gravity, ViewCompat.getLayoutDirection(this)); if ((absGravity & Gravity.TOP) == Gravity.TOP) { mShadowTop = shadowDrawable; invalidate(); } if ((absGravity & Gravity.BOTTOM) == Gravity.BOTTOM) { mShadowBottom = shadowDrawable; invalidate(); } }
From source file:com.abewy.android.apps.klyph.widget.KlyphDrawerLayout.java
/** * Set a simple drawable used for the left or right shadow. * The drawable provided must have a nonzero intrinsic width. * * @param shadowDrawable Shadow drawable to use at the edge of a drawer * @param gravity Which drawer the shadow should apply to *//*from w ww.ja v a 2s . c om*/ public void setDrawerShadow(Drawable shadowDrawable, int gravity) { /* * TODO Someone someday might want to set more complex drawables here. * They're probably nuts, but we might want to consider registering callbacks, * setting states, etc. properly. */ final int absGravity = GravityCompat.getAbsoluteGravity(gravity, ViewCompat.getLayoutDirection(this)); if ((absGravity & Gravity.LEFT) == Gravity.LEFT) { mShadowLeft = shadowDrawable; invalidate(); } if ((absGravity & Gravity.RIGHT) == Gravity.RIGHT) { mShadowRight = shadowDrawable; invalidate(); } }
From source file:edu.mecc.race2ged.navigation.DrawerLayout.java
/** * Set a simple drawable used for the left or right shadow. * The drawable provided must have a nonzero intrinsic width. * * @param shadowDrawable Shadow drawable to use at the edge of a drawer * @param gravity Which drawer the shadow should apply to *//*from ww w .j a v a 2s. c o m*/ public void setDrawerShadow(Drawable shadowDrawable, int gravity) { /* * . * They're probably nuts, but we might want to consider registering callbacks, * setting states, etc. properly. */ final int absGravity = GravityCompat.getAbsoluteGravity(gravity, ViewCompat.getLayoutDirection(this)); if ((absGravity & Gravity.LEFT) == Gravity.LEFT) { mShadowLeft = shadowDrawable; invalidate(); } if ((absGravity & Gravity.RIGHT) == Gravity.RIGHT) { mShadowRight = shadowDrawable; invalidate(); } }
From source file:com.aidy.bottomdrawerlayout.DrawerLayout.java
/** * Set a simple drawable used for the left or right shadow. The drawable * provided must have a nonzero intrinsic width. * /*w w w . jav a 2 s. com*/ * @param shadowDrawable * Shadow drawable to use at the edge of a drawer * @param gravity * Which drawer the shadow should apply to */ public void setDrawerShadow(Drawable shadowDrawable, int gravity) { /* * TODO Someone someday might want to set more complex drawables here. * They're probably nuts, but we might want to consider registering * callbacks, setting states, etc. properly. */ final int absGravity = GravityCompat.getAbsoluteGravity(gravity, ViewCompat.getLayoutDirection(this)); if ((absGravity & Gravity.LEFT) == Gravity.LEFT) { mShadowLeft = shadowDrawable; invalidate(); } if ((absGravity & Gravity.RIGHT) == Gravity.RIGHT) { mShadowRight = shadowDrawable; invalidate(); } }
From source file:com.example.verticaldrawerlayout.VerticalDrawerLayout.java
/** * Set a simple drawable used for the left or right shadow. * The drawable provided must have a nonzero intrinsic width. * // ww w .j a v a 2s. co m * @param shadowDrawable * Shadow drawable to use at the edge of a drawer * @param gravity * Which drawer the shadow should apply to */ public void setDrawerShadow(Drawable shadowDrawable, int gravity) { /* * TODO Someone someday might want to set more complex drawables here. * They're probably nuts, but we might want to consider registering * callbacks, * setting states, etc. properly. */ final int absGravity = GravityCompat.getAbsoluteGravity(gravity, ViewCompat.getLayoutDirection(this)); if ((absGravity & Gravity.TOP) == Gravity.TOP) { mShadowTop = shadowDrawable; invalidate(); } if ((absGravity & Gravity.BOTTOM) == Gravity.BOTTOM) { mShadowBottom = shadowDrawable; invalidate(); } }