本文整理匯總了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));
}