当前位置: 首页>>代码示例>>Java>>正文


Java GravityCompat.START属性代码示例

本文整理汇总了Java中android.support.v4.view.GravityCompat.START属性的典型用法代码示例。如果您正苦于以下问题:Java GravityCompat.START属性的具体用法?Java GravityCompat.START怎么用?Java GravityCompat.START使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.support.v4.view.GravityCompat的用法示例。


在下文中一共展示了GravityCompat.START属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setTextGravity

/**
 * 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
}
 
开发者ID:tylersuehr7,项目名称:empty-state-recyclerview,代码行数:22,代码来源:TextStateDisplay.java

示例2: getDx

private float getDx(final int width,
                    final int horizontalGravity,
                    final Paint paint,
                    final StaticLayout layout) {
    final boolean centered = paint.getTextAlign() == Paint.Align.CENTER;
    final float dx;
    switch (horizontalGravity) { // No support for GravityCompat.END
        case Gravity.CENTER_HORIZONTAL:
            dx = (width >> 1) - (centered ? 0 : (layout.getWidth() >> 1) - getPaddingLeft());
            break;
        default:
        case GravityCompat.START:
            dx = getPaddingLeft();
            break;
    }
    return dx;
}
 
开发者ID:tylersuehr7,项目名称:empty-state-recyclerview,代码行数:17,代码来源:TextStateDisplay.java

示例3: showIndicator

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);
    }
}
 
开发者ID:DuanJiaNing,项目名称:Musicoco,代码行数:18,代码来源:PopupIndicator.java

示例4: setDrawerShadow

public void setDrawerShadow(Drawable shadowDrawable, int gravity) {
    if (!SET_DRAWER_SHADOW_FROM_ELEVATION) {
        if ((gravity & GravityCompat.START) == GravityCompat.START) {
            this.mShadowStart = shadowDrawable;
        } else if ((gravity & GravityCompat.END) == GravityCompat.END) {
            this.mShadowEnd = shadowDrawable;
        } else if ((gravity & 3) == 3) {
            this.mShadowLeft = shadowDrawable;
        } else if ((gravity & 5) == 5) {
            this.mShadowRight = shadowDrawable;
        } else {
            return;
        }
        resolveShadowDrawables();
        invalidate();
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:17,代码来源:DrawerLayout.java

示例5: expandItemActionView

public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item) {
    Toolbar.this.ensureCollapseButtonView();
    if (Toolbar.this.mCollapseButtonView.getParent() != Toolbar.this) {
        Toolbar.this.addView(Toolbar.this.mCollapseButtonView);
    }
    Toolbar.this.mExpandedActionView = item.getActionView();
    this.mCurrentExpandedItem = item;
    if (Toolbar.this.mExpandedActionView.getParent() != Toolbar.this) {
        LayoutParams lp = Toolbar.this.generateDefaultLayoutParams();
        lp.gravity = GravityCompat.START | (Toolbar.this.mButtonGravity & 112);
        lp.mViewType = 2;
        Toolbar.this.mExpandedActionView.setLayoutParams(lp);
        Toolbar.this.addView(Toolbar.this.mExpandedActionView);
    }
    Toolbar.this.removeChildrenForExpandedActionView();
    Toolbar.this.requestLayout();
    item.setActionViewExpanded(true);
    if (Toolbar.this.mExpandedActionView instanceof CollapsibleActionView) {
        ((CollapsibleActionView) Toolbar.this.mExpandedActionView).onActionViewExpanded();
    }
    return true;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:22,代码来源:Toolbar.java

示例6: onMeasure

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    int width = ConversionUtils.getPixelsFromDp(40) * getChildCount(), height = getMeasuredHeight();
    setMeasuredDimension(width, height);

    HorizontalScrollView.LayoutParams layoutParams = (HorizontalScrollView.LayoutParams) getLayoutParams();
    if (layoutParams != null && getParent() != null && getParent() instanceof View) {
        if (((View) getParent()).getMeasuredWidth() > width)
            layoutParams.gravity = Gravity.CENTER_HORIZONTAL;
        else layoutParams.gravity = GravityCompat.START;
        setLayoutParams(layoutParams);
    }
}
 
开发者ID:TheAndroidMaster,项目名称:Metronome-Android,代码行数:14,代码来源:EmphasesLayout.java

示例7: setDrawerLockMode

public void setDrawerLockMode(int lockMode, int edgeGravity) {
    int absGravity = GravityCompat.getAbsoluteGravity(edgeGravity, ViewCompat.getLayoutDirection(this));
    switch (edgeGravity) {
        case 3:
            this.mLockModeLeft = lockMode;
            break;
        case 5:
            this.mLockModeRight = lockMode;
            break;
        case GravityCompat.START /*8388611*/:
            this.mLockModeStart = lockMode;
            break;
        case GravityCompat.END /*8388613*/:
            this.mLockModeEnd = lockMode;
            break;
    }
    if (lockMode != 0) {
        (absGravity == 3 ? this.mLeftDragger : this.mRightDragger).cancel();
    }
    switch (lockMode) {
        case 1:
            View toClose = findDrawerWithGravity(absGravity);
            if (toClose != null) {
                closeDrawer(toClose);
                return;
            }
            return;
        case 2:
            View toOpen = findDrawerWithGravity(absGravity);
            if (toOpen != null) {
                openDrawer(toOpen);
                return;
            }
            return;
        default:
            return;
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:38,代码来源:DrawerLayout.java

示例8: resolveGravity

/**
   * 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.
 */
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;
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:14,代码来源:CoordinatorLayout.java

示例9: setForegroundGravity

public void setForegroundGravity(int foregroundGravity) {
    if (this.mForegroundGravity != foregroundGravity) {
        if ((GravityCompat.RELATIVE_HORIZONTAL_GRAVITY_MASK & foregroundGravity) == 0) {
            foregroundGravity |= GravityCompat.START;
        }
        if ((foregroundGravity & 112) == 0) {
            foregroundGravity |= 48;
        }
        this.mForegroundGravity = foregroundGravity;
        if (this.mForegroundGravity == Opcodes.INVOKE_STATIC_RANGE && this.mForeground != null) {
            this.mForeground.getPadding(new Rect());
        }
        requestLayout();
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:15,代码来源:ForegroundLinearLayout.java

示例10: setGravity

public void setGravity(int gravity) {
    if (this.mGravity != gravity) {
        if ((GravityCompat.RELATIVE_HORIZONTAL_GRAVITY_MASK & gravity) == 0) {
            gravity |= GravityCompat.START;
        }
        if ((gravity & 112) == 0) {
            gravity |= 48;
        }
        this.mGravity = gravity;
        requestLayout();
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:12,代码来源:LinearLayoutCompat.java

示例11: ensureNavButtonView

private void ensureNavButtonView() {
    if (this.mNavButtonView == null) {
        this.mNavButtonView = new ImageButton(getContext(), null, R.attr.toolbarNavigationButtonStyle);
        LayoutParams lp = generateDefaultLayoutParams();
        lp.gravity = GravityCompat.START | (this.mButtonGravity & 112);
        this.mNavButtonView.setLayoutParams(lp);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:8,代码来源:Toolbar.java

示例12: onDrawState

@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);
}
 
开发者ID:tylersuehr7,项目名称:empty-state-recyclerview,代码行数:49,代码来源:ImageStateDisplay.java

示例13: resolveGravity

private static int resolveGravity(int gravity) {
    return gravity == Gravity.NO_GRAVITY ? GravityCompat.START | Gravity.TOP : gravity;
}
 
开发者ID:Learzhu,项目名称:UcMainPagerDemo-master,代码行数:3,代码来源:HeaderScrollingViewBehavior.java

示例14: getDrawerLockMode

public int getDrawerLockMode(int edgeGravity) {
    int layoutDirection = ViewCompat.getLayoutDirection(this);
    switch (edgeGravity) {
        case 3:
            if (this.mLockModeLeft != 3) {
                return this.mLockModeLeft;
            }
            int leftLockMode = layoutDirection == 0 ? this.mLockModeStart : this.mLockModeEnd;
            if (leftLockMode != 3) {
                return leftLockMode;
            }
            break;
        case 5:
            if (this.mLockModeRight != 3) {
                return this.mLockModeRight;
            }
            int rightLockMode = layoutDirection == 0 ? this.mLockModeEnd : this.mLockModeStart;
            if (rightLockMode != 3) {
                return rightLockMode;
            }
            break;
        case GravityCompat.START /*8388611*/:
            if (this.mLockModeStart != 3) {
                return this.mLockModeStart;
            }
            int startLockMode = layoutDirection == 0 ? this.mLockModeLeft : this.mLockModeRight;
            if (startLockMode != 3) {
                return startLockMode;
            }
            break;
        case GravityCompat.END /*8388613*/:
            if (this.mLockModeEnd != 3) {
                return this.mLockModeEnd;
            }
            int endLockMode = layoutDirection == 0 ? this.mLockModeRight : this.mLockModeLeft;
            if (endLockMode != 3) {
                return endLockMode;
            }
            break;
    }
    return 0;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:42,代码来源:DrawerLayout.java


注:本文中的android.support.v4.view.GravityCompat.START属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。