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


Java Dimension类代码示例

本文整理汇总了Java中android.support.annotation.Dimension的典型用法代码示例。如果您正苦于以下问题:Java Dimension类的具体用法?Java Dimension怎么用?Java Dimension使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: deriveCenter

import android.support.annotation.Dimension; //导入依赖的package包/类
/**
 * Accounting for the settings of {@link Gravity} and {@link Orientation}, find the center point
 * around which this layout manager should arrange list items.  Place the resulting coordinates
 * into {@code out}, to avoid reallocation.
 */
private Point deriveCenter(@Gravity int gravity,
                           int orientation,
                           @Dimension int radius,
                           @Dimension int peekDistance,
                           Point out) {
    final int gravitySign = gravity == Gravity.START ? -1 : 1;
    final int distanceMultiplier = gravity == Gravity.START ? 0 : 1;
    int x, y;
    switch (orientation) {
        case Orientation.HORIZONTAL:
            y = (distanceMultiplier * getHeight()) + gravitySign * (Math.abs(radius - peekDistance));
            x = getWidth() / 2;
            break;
        case Orientation.VERTICAL:
        default:
            y = getHeight() / 2;
            x = (distanceMultiplier * getWidth()) + gravitySign * (Math.abs(radius - peekDistance));
            break;
    }
    out.set(x, y);
    return out;
}
 
开发者ID:cdflynn,项目名称:turn-layout-manager,代码行数:28,代码来源:TurnLayoutManager.java

示例2: setChildOffsetsHorizontal

import android.support.annotation.Dimension; //导入依赖的package包/类
/**
 * Set bumper offsets on child views for {@link Orientation#HORIZONTAL}
 */
private void setChildOffsetsHorizontal(@Gravity int gravity,
                                       @Dimension int radius,
                                       Point center,
                                       int peekDistance) {
    for (int i = 0; i < getChildCount(); i++) {
        View child = getChildAt(i);
        RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams();
        final int yOffset = (int) resolveOffsetY(radius, child.getX() + child.getWidth() / 2, center, peekDistance);
        final int y = gravity == Gravity.START ? yOffset + layoutParams.getMarginStart()
                : getHeight() - yOffset - child.getHeight() - layoutParams.getMarginStart();

        child.layout(child.getLeft(), y, child.getRight(), child.getHeight() + y);
        setChildRotationHorizontal(gravity, child, radius, center);
    }
}
 
开发者ID:cdflynn,项目名称:turn-layout-manager,代码行数:19,代码来源:TurnLayoutManager.java

示例3: dpToPx

import android.support.annotation.Dimension; //导入依赖的package包/类
@Px
public static int dpToPx(@NonNull final Context context, @Dimension(unit = DP) final int dp) {
    if (dp < 0) {
        throw new IllegalStateException("Dimension must be > 0.");
    }

    if (dp == 0) {
        return 0;
    }

    final Resources resources = context.getResources();
    final DisplayMetrics displayMetrics = resources.getDisplayMetrics();
    final float floatResult = dp * ((float) displayMetrics.densityDpi / DENSITY_DEFAULT);

    return max(1, round(floatResult));
}
 
开发者ID:stkent,项目名称:amplify,代码行数:17,代码来源:DisplayUtils.java

示例4: setDotNormalSize

import android.support.annotation.Dimension; //导入依赖的package包/类
public void setDotNormalSize(@Dimension int dotNormalSize) {
    mDotNormalSize = dotNormalSize;

    for (int i = 0; i < sDotCount; i++) {
        for (int j = 0; j < sDotCount; j++) {
            mDotStates[i][j] = new DotState();
            mDotStates[i][j].mSize = mDotNormalSize;
        }
    }

    invalidate();
}
 
开发者ID:aritraroy,项目名称:PatternLockView,代码行数:13,代码来源:PatternLockView.java

示例5: setChildOffsets

import android.support.annotation.Dimension; //导入依赖的package包/类
/**
 * Traffic method to divert calls based on {@link Orientation}.
 *
 * @see #setChildOffsetsVertical(int, int, Point, int)
 * @see #setChildOffsetsHorizontal(int, int, Point, int)
 */
private void setChildOffsets(@Gravity int gravity,
                             int orientation,
                             @Dimension int radius,
                             Point center,
                             int peekDistance) {
    if (orientation == VERTICAL) {
        setChildOffsetsVertical(gravity, radius, center, peekDistance);
    } else if (orientation == HORIZONTAL) {
        setChildOffsetsHorizontal(gravity, radius, center, peekDistance);
    }
}
 
开发者ID:cdflynn,项目名称:turn-layout-manager,代码行数:18,代码来源:TurnLayoutManager.java

示例6: setChildOffsetsVertical

import android.support.annotation.Dimension; //导入依赖的package包/类
/**
 * Set the bumper offsets on child views for {@link Orientation#VERTICAL}
 */
private void setChildOffsetsVertical(@Gravity int gravity,
                                     @Dimension int radius,
                                     Point center,
                                     int peekDistance) {
    for (int i = 0; i < getChildCount(); i++) {
        View child = getChildAt(i);
        RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams();
        final int xOffset = (int) resolveOffsetX(radius, child.getY() + child.getHeight() / 2, center, peekDistance);
        final int x = gravity == Gravity.START ? xOffset + layoutParams.getMarginStart()
                : getWidth() - xOffset - child.getWidth() - layoutParams.getMarginStart();
        child.layout(x, child.getTop(), child.getWidth() + x, child.getBottom());
        setChildRotationVertical(gravity, child, radius, center);
    }
}
 
开发者ID:cdflynn,项目名称:turn-layout-manager,代码行数:18,代码来源:TurnLayoutManager.java

示例7: setTabStrokeWidth

import android.support.annotation.Dimension; //导入依赖的package包/类
boolean setTabStrokeWidth(@Dimension int strokeWidth) {
    boolean hasChanged = false;
    if (this.strokeWidth != strokeWidth) {
        this.strokeWidth = strokeWidth;
        updateCornerStateDrawable();
        hasChanged = true;
    }
    return hasChanged;
}
 
开发者ID:ImDobyDad,项目名称:SingleSelectBar,代码行数:10,代码来源:ResHelper.java

示例8: setTabStrokeWidth

import android.support.annotation.Dimension; //导入依赖的package包/类
/**
 * Set a dimension for border and divider.
 *
 * @param width The width of border and divider.
 */
public void setTabStrokeWidth(@Dimension int width) {
    if (resHelper.setTabStrokeWidth(width)) {
        updateBackground();
        invalidate();
    }
}
 
开发者ID:ImDobyDad,项目名称:SingleSelectBar,代码行数:12,代码来源:SingleSelectBar.java

示例9: px

import android.support.annotation.Dimension; //导入依赖的package包/类
@Contract(pure = true)
@Px static int px(@Dimension(unit = Dimension.DP) int dp) {
    float dpi = Resources.getSystem().getDisplayMetrics().density;
    dpi = dpi > 100/*120, 160, 213, 240, 320, 480 or 640 dpi*/ ? dpi / 160f : dpi;
    dpi = dpi == 0 ? 1f : dpi;
    return (int) (dp * dpi);
}
 
开发者ID:customerly,项目名称:Customerly-Android-SDK,代码行数:8,代码来源:IU_Utils.java

示例10: dpToPixel

import android.support.annotation.Dimension; //导入依赖的package包/类
/**
 * Converts dps to pixels nicely.
 *
 * @param context the Context for getting the resources
 * @param dp      dimension in dps
 * @return dimension in pixels
 */
protected static int dpToPixel(@NonNull Context context, @Dimension(unit = DP) float dp) {
    Resources resources = context.getResources();
    DisplayMetrics metrics = resources.getDisplayMetrics();

    try {
        return (int) (dp * metrics.density);
    } catch (NoSuchFieldError ignored) {
        return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, metrics);
    }
}
 
开发者ID:roughike,项目名称:BottomBar,代码行数:18,代码来源:MiscUtils.java

示例11: getToolbarHeight

import android.support.annotation.Dimension; //导入依赖的package包/类
/**
 * Retrieves the toolbar height of the current app theme.
 *
 * @param theme the device {@link Theme}
 * @param actionBarSize the current {@link ActionBar} size
 * @return the toolbar height of the current app theme
 */
@Dimension(unit = Dimension.DP)
public static int getToolbarHeight(@NonNull Theme theme, @AttrRes int actionBarSize) {
  final TypedArray styledAttributes = theme.obtainStyledAttributes(new int[] {actionBarSize});
  int toolbarHeight = (int) styledAttributes.getDimension(0, 0);
  styledAttributes.recycle();
  return toolbarHeight;
}
 
开发者ID:xmartlabs,项目名称:bigbang,代码行数:15,代码来源:MetricsHelper.java

示例12: InsetItemDecoration

import android.support.annotation.Dimension; //导入依赖的package包/类
public InsetItemDecoration(@ColorInt int backgroundColor, @Dimension int padding, String key, String value) {
    this.key = key;
    this.value = value;
    paint = new Paint();
    paint.setColor(backgroundColor);
    this.padding = padding;
}
 
开发者ID:lisawray,项目名称:groupie,代码行数:8,代码来源:InsetItemDecoration.java

示例13: setLayoutLeftPadding

import android.support.annotation.Dimension; //导入依赖的package包/类
private void setLayoutLeftPadding(ComplexComment complexComment) {
  final int level = complexComment.getLevel();
  int baseMargin =
      AptoideUtils.ScreenU.getPixelsForDip(MARGIN_IN_DIP, getContext().getResources());
  @Dimension int leftMargin = level < 2 ? baseMargin : baseMargin * level;
  outerLayout.setPadding(leftMargin, outerLayout.getPaddingTop(), baseMargin,
      outerLayout.getPaddingBottom());
}
 
开发者ID:Aptoide,项目名称:aptoide-client-v8,代码行数:9,代码来源:CommentWidget.java

示例14: setPrimaryTextSize

import android.support.annotation.Dimension; //导入依赖的package包/类
/**
 * Set the primary text font size.
 *
 * @param size The primary text font size
 * @return This Builder object to allow for chaining of calls to set methods
 */
@NonNull
public T setPrimaryTextSize(@Dimension final float size)
{
    mPrimaryTextSize = size;
    return (T) this;
}
 
开发者ID:sjwall,项目名称:MaterialTapTargetPrompt,代码行数:13,代码来源:PromptOptions.java

示例15: setSecondaryTextSize

import android.support.annotation.Dimension; //导入依赖的package包/类
/**
 * Set the secondary text font size.
 *
 * @param size The secondary text font size
 * @return This Builder object to allow for chaining of calls to set methods
 */
@NonNull
public T setSecondaryTextSize(@Dimension final float size)
{
    mSecondaryTextSize = size;
    return (T) this;
}
 
开发者ID:sjwall,项目名称:MaterialTapTargetPrompt,代码行数:13,代码来源:PromptOptions.java


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