Java Code Examples for android.support.v4.view.GravityCompat#START
The following examples show how to use
android.support.v4.view.GravityCompat#START .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PopupIndicator.java From sealrtc-android with MIT License | 6 votes |
public void showIndicator(View parent, Rect touchBounds) { if (isShowing()) { mPopupView.mMarker.animateOpen(); return; } IBinder windowToken = parent.getWindowToken(); if (windowToken != null) { WindowManager.LayoutParams p = createPopupLayout(windowToken); p.gravity = Gravity.TOP | GravityCompat.START; updateLayoutParamsForPosiion(parent, p, touchBounds.bottom); mShowing = true; translateViewIntoPosition(touchBounds.centerX()); invokePopup(p); } }
Example 2
Source File: TextStateDisplay.java From empty-state-recyclerview with MIT License | 6 votes |
/** * Sets the overall alignment for the text (supports all gravity variations * except for RIGHT and END). * @param gravity Text gravity */ public void setTextGravity(int gravity) { // Let's adjust paint alignment to fit horizontal gravity (END not supported) final int horizontalGravity = Gravity.getAbsoluteGravity(gravity, ViewCompat.LAYOUT_DIRECTION_LTR)&Gravity.HORIZONTAL_GRAVITY_MASK; switch (horizontalGravity) { case GravityCompat.START: this.titlePaint.setTextAlign(Paint.Align.LEFT); this.subtitlePaint.setTextAlign(Paint.Align.LEFT); break; case Gravity.CENTER_HORIZONTAL: this.titlePaint.setTextAlign(Paint.Align.CENTER); this.subtitlePaint.setTextAlign(Paint.Align.CENTER); break; } this.textGravity = gravity; // No invalidation needed }
Example 3
Source File: PopupIndicator.java From android-open-project-demo with Apache License 2.0 | 6 votes |
public void showIndicator(View parent, Rect touchBounds) { if (isShowing()) { mPopupView.mMarker.animateOpen(); return; } IBinder windowToken = parent.getWindowToken(); if (windowToken != null) { WindowManager.LayoutParams p = createPopupLayout(windowToken); p.gravity = Gravity.TOP | GravityCompat.START; updateLayoutParamsForPosiion(parent, p, touchBounds.bottom); mShowing = true; translateViewIntoPosition(touchBounds.centerX()); invokePopup(p); } }
Example 4
Source File: PopupIndicator.java From PLDroidShortVideo with Apache License 2.0 | 6 votes |
public void showIndicator(View parent, Rect touchBounds) { if (isShowing()) { mPopupView.mMarker.animateOpen(); return; } IBinder windowToken = parent.getWindowToken(); if (windowToken != null) { WindowManager.LayoutParams p = createPopupLayout(windowToken); p.gravity = Gravity.TOP | GravityCompat.START; updateLayoutParamsForPosiion(parent, p, touchBounds.bottom); mShowing = true; translateViewIntoPosition(touchBounds.centerX()); invokePopup(p); } }
Example 5
Source File: PopupIndicator.java From Musicoco with Apache License 2.0 | 6 votes |
public void showIndicator(View parent, Rect touchBounds) { if (isShowing()) { mPopupView.mMarker.animateOpen(); return; } IBinder windowToken = parent.getWindowToken(); if (windowToken != null) { WindowManager.LayoutParams p = createPopupLayout(windowToken); p.gravity = Gravity.TOP | GravityCompat.START; updateLayoutParamsForPosiion(parent, p, touchBounds.bottom); mShowing = true; translateViewIntoPosition(touchBounds.centerX()); invokePopup(p); } }
Example 6
Source File: PopupIndicator.java From AndroidSweetBehavior with Apache License 2.0 | 6 votes |
public void showIndicator(View parent) { if (isShowing()) { // mPopupView.mMarker.animateOpen(); return; } IBinder windowToken = parent.getWindowToken(); if (windowToken != null) { WindowManager.LayoutParams p = createPopupLayout(windowToken); p.gravity = Gravity.TOP | GravityCompat.START; updateLayoutParamsForPosiion(parent, p); mShowing = true; invokePopup(p); } }
Example 7
Source File: TranslucentDrawerLayout.java From 920-text-editor-v2 with Apache License 2.0 | 6 votes |
/** * Set a simple drawable used for the left or right shadow. The drawable provided must have a * nonzero intrinsic width. For API 21 and above, an elevation will be set on the drawer * instead of the drawable provided. * * <p>Note that for better support for both left-to-right and right-to-left layout * directions, a drawable for RTL layout (in additional to the one in LTR layout) can be * defined with a resource qualifier "ldrtl" for API 17 and above with the gravity * {@link GravityCompat#START}. Alternatively, for API 23 and above, the drawable can * auto-mirrored such that the drawable will be mirrored in RTL layout.</p> * * @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, @EdgeGravity 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. */ if (SET_DRAWER_SHADOW_FROM_ELEVATION) { // No op. Drawer shadow will come from setting an elevation on the drawer. return; } if ((gravity & GravityCompat.START) == GravityCompat.START) { mShadowStart = shadowDrawable; } else if ((gravity & GravityCompat.END) == GravityCompat.END) { mShadowEnd = shadowDrawable; } else if ((gravity & Gravity.LEFT) == Gravity.LEFT) { mShadowLeft = shadowDrawable; } else if ((gravity & Gravity.RIGHT) == Gravity.RIGHT) { mShadowRight = shadowDrawable; } else { return; } resolveShadowDrawables(); invalidate(); }
Example 8
Source File: PopupIndicator.java From Panoramic-Screenshot with GNU General Public License v3.0 | 6 votes |
public void showIndicator(View parent, Rect touchBounds) { if (isShowing()) { mPopupView.mMarker.animateOpen(); return; } IBinder windowToken = parent.getWindowToken(); if (windowToken != null) { WindowManager.LayoutParams p = createPopupLayout(windowToken); p.gravity = Gravity.TOP | GravityCompat.START; updateLayoutParamsForPosiion(parent, p, touchBounds.bottom); mShowing = true; translateViewIntoPosition(touchBounds.centerX()); invokePopup(p); } }
Example 9
Source File: PopupIndicator.java From UltimateAndroid with Apache License 2.0 | 6 votes |
public void showIndicator(View parent, Rect touchBounds) { if (isShowing()) { mPopupView.mMarker.animateOpen(); return; } IBinder windowToken = parent.getWindowToken(); if (windowToken != null) { WindowManager.LayoutParams p = createPopupLayout(windowToken); p.gravity = Gravity.TOP | GravityCompat.START; updateLayoutParamsForPosiion(parent, p, touchBounds.bottom); mShowing = true; translateViewIntoPosition(touchBounds.centerX()); invokePopup(p); } }
Example 10
Source File: PopupIndicator.java From IdealMedia with Apache License 2.0 | 6 votes |
public void showIndicator(View parent, Rect touchBounds) { if (isShowing()) { mPopupView.mMarker.animateOpen(); return; } IBinder windowToken = parent.getWindowToken(); if (windowToken != null) { WindowManager.LayoutParams p = createPopupLayout(windowToken); p.gravity = Gravity.TOP | GravityCompat.START; updateLayoutParamsForPosiion(parent, p, touchBounds.bottom); mShowing = true; translateViewIntoPosition(touchBounds.centerX()); invokePopup(p); } }
Example 11
Source File: PopupIndicator.java From SwipeBack with GNU General Public License v3.0 | 6 votes |
public void showIndicator(View parent, Rect touchBounds) { if (isShowing()) { mPopupView.mMarker.animateOpen(); return; } IBinder windowToken = parent.getWindowToken(); if (windowToken != null) { WindowManager.LayoutParams p = createPopupLayout(windowToken); p.gravity = Gravity.TOP | GravityCompat.START; updateLayoutParamsForPosiion(parent, p, touchBounds.bottom); mShowing = true; translateViewIntoPosition(touchBounds.centerX()); invokePopup(p); } }
Example 12
Source File: PopupIndicator.java From FuAgoraDemoDroid with MIT License | 6 votes |
public void showIndicator(View parent, Rect touchBounds) { if (isShowing()) { mPopupView.mMarker.animateOpen(); return; } IBinder windowToken = parent.getWindowToken(); if (windowToken != null) { WindowManager.LayoutParams p = createPopupLayout(windowToken); p.gravity = Gravity.TOP | GravityCompat.START; updateLayoutParamsForPosiion(parent, p, touchBounds.bottom); mShowing = true; translateViewIntoPosition(touchBounds.centerX()); invokePopup(p); } }
Example 13
Source File: HeaderScrollingViewBehavior.java From CoordinatorLayoutExample with Apache License 2.0 | 4 votes |
private static int resolveGravity(int gravity) { return gravity == Gravity.NO_GRAVITY ? GravityCompat.START | Gravity.TOP : gravity; }
Example 14
Source File: TranslucentDrawerLayout.java From 920-text-editor-v2 with Apache License 2.0 | 4 votes |
/** * Enable or disable interaction with the given drawer. * * <p>This allows the application to restrict the user's ability to open or close * the given drawer. DrawerLayout will still respond to calls to {@link #openDrawer(int)}, * {@link #closeDrawer(int)} and friends if a drawer is locked.</p> * * <p>Locking a drawer open or closed will implicitly open or close * that drawer as appropriate.</p> * * @param lockMode The new lock mode for the given drawer. One of {@link #LOCK_MODE_UNLOCKED}, * {@link #LOCK_MODE_LOCKED_CLOSED} or {@link #LOCK_MODE_LOCKED_OPEN}. * @param edgeGravity Gravity.LEFT, RIGHT, START or END. * Expresses which drawer to change the mode for. * * @see #LOCK_MODE_UNLOCKED * @see #LOCK_MODE_LOCKED_CLOSED * @see #LOCK_MODE_LOCKED_OPEN */ public void setDrawerLockMode(@LockMode int lockMode, @EdgeGravity int edgeGravity) { final int absGravity = GravityCompat.getAbsoluteGravity(edgeGravity, ViewCompat.getLayoutDirection(this)); switch (edgeGravity) { case Gravity.LEFT: mLockModeLeft = lockMode; break; case Gravity.RIGHT: mLockModeRight = lockMode; break; case GravityCompat.START: mLockModeStart = lockMode; break; case GravityCompat.END: mLockModeEnd = lockMode; break; } if (lockMode != LOCK_MODE_UNLOCKED) { // Cancel interaction in progress final ViewDragHelper helper = absGravity == Gravity.LEFT ? mLeftDragger : mRightDragger; helper.cancel(); } switch (lockMode) { case LOCK_MODE_LOCKED_OPEN: final View toOpen = findDrawerWithGravity(absGravity); if (toOpen != null) { openDrawer(toOpen); } break; case LOCK_MODE_LOCKED_CLOSED: final View toClose = findDrawerWithGravity(absGravity); if (toClose != null) { closeDrawer(toClose); } break; // default: do nothing } }
Example 15
Source File: HeaderScrollingViewBehavior.java From UcMainPagerDemo with Apache License 2.0 | 4 votes |
private static int resolveGravity(int gravity) { return gravity == Gravity.NO_GRAVITY ? GravityCompat.START | Gravity.TOP : gravity; }
Example 16
Source File: HeaderScrollingViewBehavior.java From CoordinatorLayoutExample with Apache License 2.0 | 4 votes |
private static int resolveGravity(int gravity) { return gravity == Gravity.NO_GRAVITY ? GravityCompat.START | Gravity.TOP : gravity; }
Example 17
Source File: HeaderScrollingViewBehavior.java From BehaviorDemo with Apache License 2.0 | 4 votes |
private static int resolveGravity(int gravity) { return gravity == Gravity.NO_GRAVITY ? GravityCompat.START | Gravity.TOP : gravity; }
Example 18
Source File: HeaderScrollingViewBehavior.java From CoordinatorLayoutExample with Apache License 2.0 | 4 votes |
private static int resolveGravity(int gravity) { return gravity == Gravity.NO_GRAVITY ? GravityCompat.START | Gravity.TOP : gravity; }
Example 19
Source File: ImageStateDisplay.java From empty-state-recyclerview with MIT License | 4 votes |
@Override public void onDrawState(EmptyStateRecyclerView rv, Canvas canvas) { final int width = rv.getMeasuredWidth(); final int height = rv.getMeasuredHeight(); configureImage(width, height); final int horizontalGravity = Gravity.getAbsoluteGravity(imageGravity, ViewCompat.getLayoutDirection(rv))&Gravity.HORIZONTAL_GRAVITY_MASK; final int verticalGravity = imageGravity&Gravity.VERTICAL_GRAVITY_MASK; // Account for horizontal gravity float dx; switch (horizontalGravity) { case Gravity.CENTER_HORIZONTAL: dx = (width >> 1) - (image.getWidth() >> 1); break; case GravityCompat.END: dx = width - image.getWidth(); break; default: case GravityCompat.START: dx = 0; break; } // Account for vertical gravity float dy; switch (verticalGravity) { case Gravity.CENTER_VERTICAL: dy = (height >> 1) - (image.getHeight() >> 1); break; case Gravity.BOTTOM: dy = height - image.getHeight(); break; default: case Gravity.TOP: dy = 0; break; } // Account for the set margins dx -= getPaddingLeft(); // Left margin dx += getPaddingRight(); // Right margin dy += getPaddingTop(); // Top margin dy -= getPaddingBottom(); // Bottom margin // Draw bitmap using locations based on gravity canvas.drawBitmap(image, dx, dy, null); }
Example 20
Source File: CoordinatorLayout.java From ticdesign with Apache License 2.0 | 2 votes |
/** * Return the given gravity value or the default if the passed value is NO_GRAVITY. * This should be used for children that are not anchored to another view or a keyline. */ private static int resolveGravity(int gravity) { return gravity == Gravity.NO_GRAVITY ? GravityCompat.START | Gravity.TOP : gravity; }