本文整理汇总了Java中android.support.annotation.DimenRes类的典型用法代码示例。如果您正苦于以下问题:Java DimenRes类的具体用法?Java DimenRes怎么用?Java DimenRes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DimenRes类属于android.support.annotation包,在下文中一共展示了DimenRes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEmoji
import android.support.annotation.DimenRes; //导入依赖的package包/类
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;
}
示例2: create
import android.support.annotation.DimenRes; //导入依赖的package包/类
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();
}
示例3: setShadowsHeightDimens
import android.support.annotation.DimenRes; //导入依赖的package包/类
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();
}
示例4: getDimension
import android.support.annotation.DimenRes; //导入依赖的package包/类
@Override
public float getDimension(@DimenRes int id) throws NotFoundException {
int realId = getCorrespondResId(id);
if (realId > 0) {
return mSkinResources.getDimension(realId);
}
return super.getDimension(id);
}
示例5: getDimensionPixelSize
import android.support.annotation.DimenRes; //导入依赖的package包/类
@Override
public int getDimensionPixelSize(@DimenRes int id) throws NotFoundException {
int realId = getCorrespondResId(id);
if (realId > 0) {
return mSkinResources.getDimensionPixelSize(realId);
}
return super.getDimensionPixelSize(id);
}
示例6: margin
import android.support.annotation.DimenRes; //导入依赖的package包/类
public Builder margin(@DimenRes int commonMargin) {
margin.add(commonMargin);
margin.add(commonMargin);
margin.add(commonMargin);
margin.add(commonMargin);
return this;
}
示例7: setAvatarSize
import android.support.annotation.DimenRes; //导入依赖的package包/类
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);
}
示例8: setContainerPadding
import android.support.annotation.DimenRes; //导入依赖的package包/类
/**
* 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;
}
示例9: setDialogRadius
import android.support.annotation.DimenRes; //导入依赖的package包/类
public Builder setDialogRadius(@DimenRes int dialogRadiusDimen) {
this.dialogRadius = context.getResources().getDimensionPixelSize(dialogRadiusDimen);
return this;
}
示例10: sizeResId
import android.support.annotation.DimenRes; //导入依赖的package包/类
public T sizeResId(@DimenRes int sizeId) {
return size(mResources.getDimensionPixelSize(sizeId));
}
示例11: setErrorTextSizeResource
import android.support.annotation.DimenRes; //导入依赖的package包/类
public Builder setErrorTextSizeResource(@DimenRes int mErrorTextSizeRes) {
return setErrorTextSize(getDimensionPixelSize(mErrorTextSizeRes));
}
示例12: marginResId
import android.support.annotation.DimenRes; //导入依赖的package包/类
public Builder marginResId(@DimenRes int leftMarginId, @DimenRes int rightMarginId) {
return margin(mResources.getDimensionPixelSize(leftMarginId),
mResources.getDimensionPixelSize(rightMarginId));
}
示例13: marginResId
import android.support.annotation.DimenRes; //导入依赖的package包/类
public Builder marginResId(@DimenRes int topMarginId, @DimenRes int bottomMarginId) {
return margin(mResources.getDimensionPixelSize(topMarginId),
mResources.getDimensionPixelSize(bottomMarginId));
}
示例14: setCornerRadiusDimen
import android.support.annotation.DimenRes; //导入依赖的package包/类
public void setCornerRadiusDimen(@DimenRes int resId) {
float radius = getResources().getDimension(resId);
setCornerRadius(radius, radius, radius, radius);
}
示例15: setNoNetTextSizeResource
import android.support.annotation.DimenRes; //导入依赖的package包/类
public Builder setNoNetTextSizeResource(@DimenRes int mNoNetTextSizeRes) {
return setNoNetTextSize(getDimensionPixelSize(mNoNetTextSizeRes));
}