Java Code Examples for android.support.annotation.DimenRes

The following are top voted examples for showing how to use android.support.annotation.DimenRes. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: shortstories   File: BitmapUtil.java   View source code 7 votes vote down vote up
private static Bitmap getEmoji(
        Context context, String emoji, @DimenRes int sizeResId, @DimenRes int insetResId) {
    if (context == null || TextUtils.isEmpty(emoji)) {
        return null;
    }
    int size = context.getResources().getDimensionPixelSize(sizeResId);
    int inset = context.getResources().getDimensionPixelSize(insetResId);
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setStyle(Paint.Style.FILL);
    paint.setTextAlign(Paint.Align.LEFT);
    paint.setTextSize(size);
    float baseline = -paint.ascent();
    int width = (int) (paint.measureText(emoji) + 0.5f);
    int height = (int) (baseline + paint.descent() + 0.5f);
    Bitmap bitmap = Bitmap.createBitmap(width + inset * 2, height + inset * 2, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    canvas.drawText(emoji, inset, baseline + inset, paint);
    return bitmap;
}
 
Example 2
Project: music-player   File: CharacterDrawable.java   View source code 5 votes vote down vote up
public static CharacterDrawable create(Context context, char character, boolean roundAsCircle, @DimenRes int padding) {
    return new CharacterDrawable.Builder()
            .setCharacter(character)
            .setBackgroundRoundAsCircle(roundAsCircle)
            .setCharacterPadding(context.getResources().getDimensionPixelSize(padding))
            .build();
}
 
Example 3
Project: ShadowFrameLayout   File: ShadowFrameLayout.java   View source code 5 votes vote down vote up
public void setShadowsHeightDimens(@DimenRes int left, @DimenRes int top, @DimenRes int right, @DimenRes int bottom) {
    mShadowLeftHeight = mResources.getDimensionPixelOffset(left);
    mShadowTopHeight = mResources.getDimensionPixelOffset(top);
    mShadowRightHeight = mResources.getDimensionPixelOffset(right);
    mShadowBottomHeight = mResources.getDimensionPixelOffset(bottom);
    invalidate();
}
 
Example 4
Project: SkinFramework   File: ComposedResources.java   View source code 5 votes vote down vote up
@Override
public float getDimension(@DimenRes int id) throws NotFoundException {
    int realId = getCorrespondResId(id);
    if (realId > 0) {
        return mSkinResources.getDimension(realId);
    }
    return super.getDimension(id);
}
 
Example 5
Project: SkinFramework   File: ComposedResources.java   View source code 5 votes vote down vote up
@Override
public int getDimensionPixelSize(@DimenRes int id) throws NotFoundException {
    int realId = getCorrespondResId(id);
    if (realId > 0) {
        return mSkinResources.getDimensionPixelSize(realId);
    }
    return super.getDimensionPixelSize(id);
}
 
Example 6
Project: LiteReader   File: ButtonViewModel.java   View source code 5 votes vote down vote up
public Builder margin(@DimenRes int commonMargin) {
    margin.add(commonMargin);
    margin.add(commonMargin);
    margin.add(commonMargin);
    margin.add(commonMargin);
    return this;
}
 
Example 7
Project: Nird2   File: AuthorView.java   View source code 5 votes vote down vote up
private void setAvatarSize(@DimenRes int res) {
	LayoutParams params = (LayoutParams) avatar.getLayoutParams();
	int size = getResources().getDimensionPixelSize(res);
	params.height = size;
	params.width = size;
	avatar.setLayoutParams(params);
}
 
Example 8
Project: Nird2   File: AuthorView.java   View source code 5 votes vote down vote up
private void setAvatarSize(@DimenRes int res) {
	LayoutParams params = (LayoutParams) avatar.getLayoutParams();
	int size = getResources().getDimensionPixelSize(res);
	params.height = size;
	params.width = size;
	avatar.setLayoutParams(params);
}
 
Example 9
Project: imageviewer   File: ImageViewer.java   View source code 5 votes vote down vote up
/**
 * Set {@code start}, {@code top}, {@code end} and {@code bottom} padding for zooming and scrolling area using dimension.
 *
 * @return This Builder object to allow for chaining of calls to set methods
 */
public Builder setContainerPadding(Context context,
                                   @DimenRes int start, @DimenRes int top,
                                   @DimenRes int end, @DimenRes int bottom) {
    setContainerPaddingPx(
            Math.round(context.getResources().getDimension(start)),
            Math.round(context.getResources().getDimension(top)),
            Math.round(context.getResources().getDimension(end)),
            Math.round(context.getResources().getDimension(bottom))
    );
    return this;
}
 
Example 10
Project: NoInternetDialog   File: NoInternetDialog.java   View source code 4 votes vote down vote up
public Builder setDialogRadius(@DimenRes int dialogRadiusDimen) {
    this.dialogRadius = context.getResources().getDimensionPixelSize(dialogRadiusDimen);
    return this;
}
 
Example 11
Project: GitHub   File: FlexibleDividerDecoration.java   View source code 4 votes vote down vote up
public T sizeResId(@DimenRes int sizeId) {
    return size(mResources.getDimensionPixelSize(sizeId));
}
 
Example 12
Project: FastLib   File: FastMultiStatusView.java   View source code 4 votes vote down vote up
public Builder setErrorTextSizeResource(@DimenRes int mErrorTextSizeRes) {
    return setErrorTextSize(getDimensionPixelSize(mErrorTextSizeRes));
}
 
Example 13
Project: AppFirCloud   File: HorizontalDividerItemDecoration.java   View source code 4 votes vote down vote up
public Builder marginResId(@DimenRes int leftMarginId, @DimenRes int rightMarginId) {
    return margin(mResources.getDimensionPixelSize(leftMarginId),
            mResources.getDimensionPixelSize(rightMarginId));
}
 
Example 14
Project: AppFirCloud   File: VerticalDividerItemDecoration.java   View source code 4 votes vote down vote up
public Builder marginResId(@DimenRes int topMarginId, @DimenRes int bottomMarginId) {
    return margin(mResources.getDimensionPixelSize(topMarginId),
            mResources.getDimensionPixelSize(bottomMarginId));
}
 
Example 15
Project: boohee_v5.6   File: RoundedImageView.java   View source code 4 votes vote down vote up
public void setCornerRadiusDimen(@DimenRes int resId) {
    float radius = getResources().getDimension(resId);
    setCornerRadius(radius, radius, radius, radius);
}
 
Example 16
Project: FastLib   File: FastMultiStatusView.java   View source code 4 votes vote down vote up
public Builder setNoNetTextSizeResource(@DimenRes int mNoNetTextSizeRes) {
    return setNoNetTextSize(getDimensionPixelSize(mNoNetTextSizeRes));
}
 
Example 17
Project: GitHub   File: VerticalDividerItemDecoration.java   View source code 4 votes vote down vote up
public Builder marginResId(@DimenRes int verticalMarginId) {
    return marginResId(verticalMarginId, verticalMarginId);
}
 
Example 18
Project: AppFirCloud   File: FlexibleDividerDecoration.java   View source code 4 votes vote down vote up
public T sizeResId(@DimenRes int sizeId) {
    return size(mResources.getDimensionPixelSize(sizeId));
}
 
Example 19
Project: GitHub   File: MaterialSimpleListItem.java   View source code 4 votes vote down vote up
public Builder iconPaddingRes(@DimenRes int paddingRes) {
    return iconPadding(context.getResources().getDimensionPixelSize(paddingRes));
}
 
Example 20
Project: ShadowFrameLayout   File: ShadowFrameLayout.java   View source code 4 votes vote down vote up
public void setLeftShadowDimens(@DimenRes int resource) {
    mShadowLeftHeight = mResources.getDimensionPixelOffset(resource);
    invalidate();
}
 
Example 21
Project: RLibrary   File: UIIViewImpl.java   View source code 4 votes vote down vote up
public int getDimensionPixelOffset(@DimenRes int id) {
    return getResources().getDimensionPixelOffset(id);
}
 
Example 22
Project: ShadowFrameLayout   File: ShadowFrameLayout.java   View source code 4 votes vote down vote up
public void setTopShadowDimens(@DimenRes int resource) {
    mShadowTopHeight = mResources.getDimensionPixelOffset(resource);
    invalidate();
}
 
Example 23
Project: shareNote   File: RoundedImageView.java   View source code 4 votes vote down vote up
public void setBorderWidth(@DimenRes int resId) {
  setBorderWidth(getResources().getDimension(resId));
}
 
Example 24
Project: Pluto-Android   File: BitmapDisplayConfig.java   View source code 4 votes vote down vote up
public static BitmapDisplayConfig getDefaultUserAvatarConfigByDpRes(Context context, @DimenRes int dpRes) {
	int dp2px = context.getResources().getDimensionPixelSize(dpRes);
	return getDefaultUserAvatarConfig(context, dp2px);
}
 
Example 25
Project: RendererRecyclerViewAdapter   File: ItemOffsetDecoration.java   View source code 4 votes vote down vote up
public ItemOffsetDecoration(@NonNull Context context, @DimenRes int itemOffsetId) {
	this(context.getResources().getDimensionPixelSize(itemOffsetId));
}
 
Example 26
Project: LiteReader   File: BlankViewModel.java   View source code 4 votes vote down vote up
public BlankViewModel(@DimenRes int height) {
    this.height = height;
}
 
Example 27
Project: boohee_v5.6   File: RoundedImageView.java   View source code 4 votes vote down vote up
public void setCornerRadiusDimen(int corner, @DimenRes int resId) {
    setCornerRadius(corner, (float) getResources().getDimensionPixelSize(resId));
}
 
Example 28
Project: LiteReader   File: HeaderItemViewModel.java   View source code 4 votes vote down vote up
public HeaderItemViewModel textSize(@DimenRes int testSize) {
    this.textSize = testSize;
    return this;
}
 
Example 29
Project: CustomListView   File: DensityUtils.java   View source code 4 votes vote down vote up
public static int getDimens(Context context, @DimenRes int resource) {
    Resources mResources = context.getResources();
    return mResources.getDimensionPixelSize(resource);
}
 
Example 30
Project: quickblox-android   File: VideoConversationFragment.java   View source code 4 votes vote down vote up
public DividerItemDecoration(@NonNull Context context, @DimenRes int dimensionDivider) {
    this.space = context.getResources().getDimensionPixelSize(dimensionDivider);
}
 
Example 31
Project: quickblox-android   File: ResourceUtils.java   View source code 4 votes vote down vote up
public static int getDimen(@DimenRes int dimenId) {
    return (int) CoreApp.getInstance().getResources().getDimension(dimenId);
}
 
Example 32
Project: androidgithub   File: FlexibleDividerDecoration.java   View source code 4 votes vote down vote up
public T sizeResId(@DimenRes int sizeId) {
    return size(mResources.getDimensionPixelSize(sizeId));
}
 
Example 33
Project: FastLib   File: FastMultiStatusView.java   View source code 4 votes vote down vote up
public Builder setEmptyTextSizeResource(@DimenRes int mEmptyTextSizeRes) {
    return setEmptyTextSize(getDimensionPixelSize(mEmptyTextSizeRes));
}
 
Example 34
Project: imageviewer   File: ImageViewer.java   View source code 4 votes vote down vote up
/**
 * Set common padding for zooming and scrolling area using dimension.
 *
 * @return This Builder object to allow for chaining of calls to set methods
 */
public Builder setContainerPadding(Context context, @DimenRes int padding) {
    int paddingPx = Math.round(context.getResources().getDimension(padding));
    setContainerPaddingPx(paddingPx, paddingPx, paddingPx, paddingPx);
    return this;
}
 
Example 35
Project: ContactLoader   File: LineDividerItemDecoration.java   View source code 4 votes vote down vote up
public void setHorizontalPadding(@DimenRes int horizontalPadding) {
    this.horizontalPadding = mContext.getResources().getDimensionPixelSize(horizontalPadding);
}
 
Example 36
Project: FastLib   File: FastLoadMoreView.java   View source code 4 votes vote down vote up
public Builder setLoadFailTextSizeResource(@DimenRes int mLoadFailTextSizeRes) {
    return setLoadFailTextSize(getDimensionPixelSize(mLoadFailTextSizeRes));
}
 
Example 37
Project: RX_Demo   File: VerticalDividerItemDecoration.java   View source code 4 votes vote down vote up
public Builder marginResId(@DimenRes int verticalMarginId) {
    return marginResId(verticalMarginId, verticalMarginId);
}
 
Example 38
Project: Pocket-Plays-for-Twitch   File: IntroductoryOverlay.java   View source code 4 votes vote down vote up
/**
 * Sets the radius of the "hole" around the cast button. This will override the value
 * specified in the resource file and is optional.
 */
public Builder setFocusRadiusId(@DimenRes int radiusId) {
    mRadius = mContext.getResources().getDimension(radiusId);
    return this;
}
 
Example 39
Project: RX_Demo   File: HorizontalDividerItemDecoration.java   View source code 4 votes vote down vote up
public Builder marginResId(@DimenRes int horizontalMarginId) {
    return marginResId(horizontalMarginId, horizontalMarginId);
}
 
Example 40
Project: diycode   File: PositionAnimExpectation.java   View source code 4 votes vote down vote up
public PositionAnimExpectation withMarginDimen(@DimenRes int marginRes){
    this.marginRes = marginRes;
    return this;
}