本文整理汇总了Java中android.content.res.TypedArray.getDimension方法的典型用法代码示例。如果您正苦于以下问题:Java TypedArray.getDimension方法的具体用法?Java TypedArray.getDimension怎么用?Java TypedArray.getDimension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.res.TypedArray
的用法示例。
在下文中一共展示了TypedArray.getDimension方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void init(@Nullable final AttributeSet attrs) {
if (!isInEditMode()) {
PrismojiManager.getInstance().verifyInstalled();
}
if (attrs == null) {
emojiSize = (int) getTextSize();
} else {
final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.emoji);
try {
emojiSize = (int) a.getDimension(R.styleable.emoji_emojiSize, getTextSize());
} finally {
a.recycle();
}
}
setText(getText());
}
示例2: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
public void init(Context context, AttributeSet attrs) {
dotRadius = (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, 8, context.getResources().getDisplayMetrics()
);
lineWidth = (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, 4, context.getResources().getDisplayMetrics()
);
if (attrs != null) {
TypedArray a = context.getTheme().obtainStyledAttributes(
attrs,
R.styleable.TimeLineView,
0, 0);
try {
dotRadius = (int) a.getDimension(R.styleable.TimeLineView_dotRadius, dotRadius);
lineWidth = (int) a.getDimension(R.styleable.TimeLineView_lineWidth, lineWidth);
} finally {
a.recycle();
}
}
setOverScrollMode(OVER_SCROLL_NEVER);
setHasFixedSize(true);
setLayoutManager(new LinearLayoutManager(getContext()));
}
示例3: FlowViewHorizontal
import android.content.res.TypedArray; //导入方法依赖的package包/类
public FlowViewHorizontal(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mContext = context;
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.FlowViewHorizontal);
bgRadius = ta.getDimension(R.styleable.FlowViewHorizontal_h_bg_radius, 10);
proRadius = ta.getDimension(R.styleable.FlowViewHorizontal_h_pro_radius, 8);
lineBgWidth = (int) ta.getDimension(R.styleable.FlowViewHorizontal_h_bg_width, 3f);
bgColor = ta.getColor(R.styleable.FlowViewHorizontal_h_bg_color, Color.parseColor("#cdcbcc"));
lineProWidth = (int) ta.getDimension(R.styleable.FlowViewHorizontal_h_pro_width, 2f);
proColor = ta.getColor(R.styleable.FlowViewHorizontal_h_pro_color, Color.parseColor("#029dd5"));
textPadding = (int) ta.getDimension(R.styleable.FlowViewHorizontal_h_text_padding, 20);
timePadding = (int) ta.getDimension(R.styleable.FlowViewHorizontal_h_time_padding, 30);
maxStep = ta.getInt(R.styleable.FlowViewHorizontal_h_max_step, 5);
textSize = (int) ta.getDimension(R.styleable.FlowViewHorizontal_h_textsize, 20);
proStep = ta.getInt(R.styleable.FlowViewHorizontal_h_pro_step, 1);
ta.recycle();
init();
}
示例4: DrawerArrowDrawable
import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
* @param context used to get the configuration for the drawable from
*/
public DrawerArrowDrawable(Context context) {
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeJoin(Paint.Join.MITER);
mPaint.setStrokeCap(Paint.Cap.BUTT);
mPaint.setAntiAlias(true);
final TypedArray a = context.getTheme().obtainStyledAttributes(null,
R.styleable.DrawerArrowToggle, R.attr.drawerArrowStyle,
R.style.Base_Widget_Material_DrawerArrowToggle);
setColor(a.getColor(R.styleable.DrawerArrowToggle_color, 0));
setBarThickness(a.getDimension(R.styleable.DrawerArrowToggle_thickness, 0));
setSpinEnabled(a.getBoolean(R.styleable.DrawerArrowToggle_spinBars, true));
// round this because having this floating may cause bad measurements
setGapSize(Math.round(a.getDimension(R.styleable.DrawerArrowToggle_gapBetweenBars, 0)));
mSize = a.getDimensionPixelSize(R.styleable.DrawerArrowToggle_drawableSize, 0);
// round this because having this floating may cause bad measurements
mBarLength = Math.round(a.getDimension(R.styleable.DrawerArrowToggle_barLength, 0));
// round this because having this floating may cause bad measurements
mArrowHeadLength = Math.round(a.getDimension(
R.styleable.DrawerArrowToggle_arrowHeadLength, 0));
mArrowShaftLength = a.getDimension(R.styleable.DrawerArrowToggle_arrowShaftLength, 0);
a.recycle();
}
示例5: LinePageIndicator
import android.content.res.TypedArray; //导入方法依赖的package包/类
public LinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
if (isInEditMode()) return;
final Resources res = getResources();
//Load defaults from resources
final int defaultSelectedColor = res.getColor(R.color.default_line_indicator_selected_color);
final int defaultUnselectedColor = res.getColor(R.color.default_line_indicator_unselected_color);
final float defaultLineWidth = res.getDimension(R.dimen.default_line_indicator_line_width);
final float defaultGapWidth = res.getDimension(R.dimen.default_line_indicator_gap_width);
final float defaultStrokeWidth = res.getDimension(R.dimen.default_line_indicator_stroke_width);
final boolean defaultCentered = res.getBoolean(R.bool.default_line_indicator_centered);
//Retrieve styles attributes
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LinePageIndicator, defStyle, 0);
mCentered = a.getBoolean(R.styleable.LinePageIndicator_centered, defaultCentered);
mLineWidth = a.getDimension(R.styleable.LinePageIndicator_lineWidth, defaultLineWidth);
mGapWidth = a.getDimension(R.styleable.LinePageIndicator_gapWidth, defaultGapWidth);
setStrokeWidth(a.getDimension(R.styleable.LinePageIndicator_strokeWidth, defaultStrokeWidth));
mPaintUnselected.setColor(a.getColor(R.styleable.LinePageIndicator_unselectedColor, defaultUnselectedColor));
mPaintSelected.setColor(a.getColor(R.styleable.LinePageIndicator_selectedColor, defaultSelectedColor));
Drawable background = a.getDrawable(R.styleable.LinePageIndicator_android_background);
if (background != null) {
setBackgroundDrawable(background);
}
a.recycle();
final ViewConfiguration configuration = ViewConfiguration.get(context);
mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}
示例6: getDisplayHeight
import android.content.res.TypedArray; //导入方法依赖的package包/类
public static int getDisplayHeight(AppCompatActivity activity) {
int height = 0;
if (activity != null && activity.getWindowManager() != null && activity.getWindowManager().getDefaultDisplay() != null) {
Point point=new Point();
activity.getWindowManager().getDefaultDisplay().getSize(point);
height=point.y;
}
Log.e(TAG, "isSupportSmartBar:" + isSupportSmartBar);
if (isSupportSmartBar) {
int smartBarHeight = getSmartBarHeight(activity);
Log.e(TAG, "smartBarHeight:" + smartBarHeight);
height -= smartBarHeight;
}
if (activity.getSupportActionBar() != null) {
int actionbar= activity.getSupportActionBar().getHeight();
if(actionbar==0){
TypedArray actionbarSizeTypedArray=activity.obtainStyledAttributes(new int[]{android.R.attr.actionBarSize});
actionbar= (int) actionbarSizeTypedArray.getDimension(0,0);
}
Log.d(TAG, "actionbar:" + actionbar);
height -= actionbar;
}
int status = getStatusBarHeight(activity);
Log.d(TAG, "status:" + status);
height -= status;
Log.d(TAG,"height:"+height);
return height;
}
示例7: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void init(Context context,AttributeSet attrs){
TypedArray typedArray = context.obtainStyledAttributes(attrs,R.styleable.CircleBarView);
progressColor = typedArray.getColor(R.styleable.CircleBarView_progress_color,Color.GREEN);
bgColor = typedArray.getColor(R.styleable.CircleBarView_bg_color,Color.GRAY);
startAngle = typedArray.getFloat(R.styleable.CircleBarView_start_angle,0);
sweepAngle = typedArray.getFloat(R.styleable.CircleBarView_sweep_angle,360);
barWidth = typedArray.getDimension(R.styleable.CircleBarView_bar_width,DpOrPxUtils.dip2px(context,10));
typedArray.recycle();
progressNum = 0;
maxNum = 100;
defaultSize = DpOrPxUtils.dip2px(context,100);
mRectF = new RectF();
progressPaint = new Paint();
progressPaint.setStyle(Paint.Style.STROKE);//只描边,不填充
progressPaint.setColor(progressColor);
progressPaint.setAntiAlias(true);//设置抗锯齿
progressPaint.setStrokeWidth(barWidth);
progressPaint.setStrokeCap(Paint.Cap.ROUND);//设置画笔为圆角
bgPaint = new Paint();
bgPaint.setStyle(Paint.Style.STROKE);//只描边,不填充
bgPaint.setColor(bgColor);
bgPaint.setAntiAlias(true);//设置抗锯齿
bgPaint.setStrokeWidth(barWidth);
bgPaint.setStrokeCap(Paint.Cap.ROUND);
anim = new CircleBarAnim();
}
示例8: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs) {
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.RoundedImageView);
float radius = ta.getDimension(R.styleable.RoundedImageView_roundRadius, 0);
float radiusLeftTop = ta.getDimension(R.styleable.RoundedImageView_roundRadiusLeftTop, 0);
float radiusRightTop = ta.getDimension(R.styleable.RoundedImageView_roundRadiusRightTop, 0);
float radiusRightBottom = ta.getDimension(R.styleable.RoundedImageView_roundRadiusRightBottom, 0);
float radiusLeftBottom = ta.getDimension(R.styleable.RoundedImageView_roundRadiusLeftBottom, 0);
isCircle = ta.getBoolean(R.styleable.RoundedImageView_roundRadiusIsCircle, false);
ta.recycle();
if (radius != 0) {
mRadius = new float[] { radius, radius, radius, radius };
}
boolean falg = (radiusLeftTop != 0) ? true : false;
falg = (radiusRightTop != 0) ? true : falg;
falg = (radiusRightBottom != 0) ? true : falg;
falg = (radiusLeftBottom != 0) ? true : falg;
if (falg) {
mRadius = new float[] { radiusLeftTop, radiusRightTop, radiusRightBottom, radiusLeftBottom };
}
mPathFactory = new PathFactory();
mPath = new Path();
mBitmapPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mBitmapPaint.setDither(false);
}
示例9: updateStateFromTypedArray
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void updateStateFromTypedArray(TypedArray a, XmlPullParser parser) throws XmlPullParserException {
VectorDrawableCompatState state = this.mVectorState;
VPathRenderer pathRenderer = state.mVPathRenderer;
state.mTintMode = parseTintModeCompat(TypedArrayUtils.getNamedInt(a, parser, "tintMode", 6, -1), Mode.SRC_IN);
ColorStateList tint = a.getColorStateList(1);
if (tint != null) {
state.mTint = tint;
}
state.mAutoMirrored = TypedArrayUtils.getNamedBoolean(a, parser, "autoMirrored", 5, state.mAutoMirrored);
pathRenderer.mViewportWidth = TypedArrayUtils.getNamedFloat(a, parser, "viewportWidth", 7, pathRenderer.mViewportWidth);
pathRenderer.mViewportHeight = TypedArrayUtils.getNamedFloat(a, parser, "viewportHeight", 8, pathRenderer.mViewportHeight);
if (pathRenderer.mViewportWidth <= 0.0f) {
throw new XmlPullParserException(a.getPositionDescription() + "<vector> tag requires viewportWidth > 0");
} else if (pathRenderer.mViewportHeight <= 0.0f) {
throw new XmlPullParserException(a.getPositionDescription() + "<vector> tag requires viewportHeight > 0");
} else {
pathRenderer.mBaseWidth = a.getDimension(3, pathRenderer.mBaseWidth);
pathRenderer.mBaseHeight = a.getDimension(2, pathRenderer.mBaseHeight);
if (pathRenderer.mBaseWidth <= 0.0f) {
throw new XmlPullParserException(a.getPositionDescription() + "<vector> tag requires width > 0");
} else if (pathRenderer.mBaseHeight <= 0.0f) {
throw new XmlPullParserException(a.getPositionDescription() + "<vector> tag requires height > 0");
} else {
pathRenderer.setAlpha(TypedArrayUtils.getNamedFloat(a, parser, "alpha", 4, pathRenderer.getAlpha()));
String name = a.getString(0);
if (name != null) {
pathRenderer.mRootName = name;
pathRenderer.mVGTargetsMap.put(name, pathRenderer);
}
}
}
}
示例10: setTypeArray
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void setTypeArray(TypedArray typeArray) {
tag_textSize = typeArray.getInt(R.styleable.RibbonTag_tag_textSize, tag_textSize);
tag_textColor = typeArray.getColor(R.styleable.RibbonTag_tag_textColor, tag_textColor);
ribbonColor = typeArray.getColor(R.styleable.RibbonTag_tag_ribbonColor, ribbonColor);
ribbonRadius = typeArray.getInt(R.styleable.RibbonTag_tag_ribbonRadius, ribbonRadius);
padding_left = typeArray.getDimension(R.styleable.RibbonTag_tag_padding_left, padding_left);
padding_top = typeArray.getDimension(R.styleable.RibbonTag_tag_padding_top, padding_top);
padding_right = typeArray.getDimension(R.styleable.RibbonTag_tag_padding_right, padding_right);
padding_bottom = typeArray.getDimension(R.styleable.RibbonTag_tag_padding_bottom, padding_bottom);
}
示例11: obtainAttributes
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void obtainAttributes(Context context, AttributeSet attrs) {
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidingTabLayout);
mIndicatorStyle = ta.getInt(R.styleable.SlidingTabLayout_tl_indicator_style, STYLE_NORMAL);
mIndicatorColor = ta.getColor(R.styleable.SlidingTabLayout_tl_indicator_color, Color.parseColor(mIndicatorStyle == STYLE_BLOCK ? "#4B6A87" : "#ffffff"));
mIndicatorHeight = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_height,
dp2px(mIndicatorStyle == STYLE_TRIANGLE ? 4 : (mIndicatorStyle == STYLE_BLOCK ? -1 : 2)));
mIndicatorWidth = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_width, dp2px(mIndicatorStyle == STYLE_TRIANGLE ? 10 : -1));
mIndicatorCornerRadius = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_corner_radius, dp2px(mIndicatorStyle == STYLE_BLOCK ? -1 : 0));
mIndicatorMarginLeft = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_margin_left, dp2px(0));
mIndicatorMarginTop = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_margin_top, dp2px(mIndicatorStyle == STYLE_BLOCK ? 7 : 0));
mIndicatorMarginRight = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_margin_right, dp2px(0));
mIndicatorMarginBottom = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_margin_bottom, dp2px(mIndicatorStyle == STYLE_BLOCK ? 7 : 0));
mIndicatorGravity = ta.getInt(R.styleable.SlidingTabLayout_tl_indicator_gravity, Gravity.BOTTOM);
mIndicatorWidthEqualTitle = ta.getBoolean(R.styleable.SlidingTabLayout_tl_indicator_width_equal_title, false);
mUnderlineColor = ta.getColor(R.styleable.SlidingTabLayout_tl_underline_color, Color.parseColor("#ffffff"));
mUnderlineHeight = ta.getDimension(R.styleable.SlidingTabLayout_tl_underline_height, dp2px(0));
mUnderlineGravity = ta.getInt(R.styleable.SlidingTabLayout_tl_underline_gravity, Gravity.BOTTOM);
mDividerColor = ta.getColor(R.styleable.SlidingTabLayout_tl_divider_color, Color.parseColor("#ffffff"));
mDividerWidth = ta.getDimension(R.styleable.SlidingTabLayout_tl_divider_width, dp2px(0));
mDividerPadding = ta.getDimension(R.styleable.SlidingTabLayout_tl_divider_padding, dp2px(12));
mTextsize = ta.getDimension(R.styleable.SlidingTabLayout_tl_textsize, sp2px(14));
mTextSelectColor = ta.getColor(R.styleable.SlidingTabLayout_tl_textSelectColor, Color.parseColor("#ffffff"));
mTextUnselectColor = ta.getColor(R.styleable.SlidingTabLayout_tl_textUnselectColor, Color.parseColor("#AAffffff"));
mTextBold = ta.getInt(R.styleable.SlidingTabLayout_tl_textBold, TEXT_BOLD_NONE);
mTextAllCaps = ta.getBoolean(R.styleable.SlidingTabLayout_tl_textAllCaps, false);
mTabSpaceEqual = ta.getBoolean(R.styleable.SlidingTabLayout_tl_tab_space_equal, false);
mTabWidth = ta.getDimension(R.styleable.SlidingTabLayout_tl_tab_width, dp2px(-1));
mTabPadding = ta.getDimension(R.styleable.SlidingTabLayout_tl_tab_padding, mTabSpaceEqual || mTabWidth > 0 ? dp2px(0) : dp2px(20));
ta.recycle();
}
示例12: parseAttributes
import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
* Parse the attributes passed to the view from the XML
*
* @param a the attributes to parse
*/
private void parseAttributes(TypedArray a) {
// We transform the default values from DIP to pixels
DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
barWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, barWidth, metrics);
rimWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, rimWidth, metrics);
circleRadius =
(int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, circleRadius, metrics);
circleRadius =
(int) a.getDimension(R.styleable.ProgressWheel_matProg_circleRadius, circleRadius);
fillRadius = a.getBoolean(R.styleable.ProgressWheel_matProg_fillRadius, false);
barWidth = (int) a.getDimension(R.styleable.ProgressWheel_matProg_barWidth, barWidth);
rimWidth = (int) a.getDimension(R.styleable.ProgressWheel_matProg_rimWidth, rimWidth);
float baseSpinSpeed =
a.getFloat(R.styleable.ProgressWheel_matProg_spinSpeed, spinSpeed / 360.0f);
spinSpeed = baseSpinSpeed * 360;
barSpinCycleTime =
a.getInt(R.styleable.ProgressWheel_matProg_barSpinCycleTime, (int) barSpinCycleTime);
barColor = a.getColor(R.styleable.ProgressWheel_matProg_barColor, barColor);
rimColor = a.getColor(R.styleable.ProgressWheel_matProg_rimColor, rimColor);
linearProgress = a.getBoolean(R.styleable.ProgressWheel_matProg_linearProgress, false);
if (a.getBoolean(R.styleable.ProgressWheel_matProg_progressIndeterminate, false)) {
spin();
}
// Recycle
a.recycle();
}
示例13: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
* 初始化,获取设置的属性
*
* @param context
* @param attrs
*/
private void init(Context context, AttributeSet attrs) {
TypedArray attribute = context.obtainStyledAttributes(attrs,
R.styleable.WheelView);
unitHeight = (int) attribute.getDimension(
R.styleable.WheelView_unitHight, 32);
normalFont = attribute.getDimension(
R.styleable.WheelView_normalTextSize, 14.0f);
selectedFont = attribute.getDimension(
R.styleable.WheelView_selectedTextSize, 22.0f);
itemNumber = attribute.getInt(R.styleable.WheelView_itemNumber, 7);
normalColor = attribute.getColor(
R.styleable.WheelView_normalTextColor, 0xff000000);
selectedColor = attribute.getColor(
R.styleable.WheelView_selectedTextColor, 0xffff0000);
lineColor = attribute.getColor(R.styleable.WheelView_lineColor,
0xff000000);
bottomLineColor = attribute.getColor(R.styleable.WheelView_bottomLineColor,
0xffDADADA);
lineWidth = attribute.getDimension(R.styleable.WheelView_lineHeight, 2f);
firstLineAndSecondLineSpace = attribute.getDimension(R.styleable.WheelView_firstLineAndSecondLineSpace, 40f);
maskHight = attribute.getDimension(R.styleable.WheelView_maskHight,
48.0f);
noEmpty = attribute.getBoolean(R.styleable.WheelView_noEmpty, true);
isEnable = attribute
.getBoolean(R.styleable.WheelView_isEnable, true);
attribute.recycle();
controlHeight = itemNumber * unitHeight;
}
示例14: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs) {
// set scroll mode
setOverScrollMode(OVER_SCROLL_NEVER);
if (null != attrs) {
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.PullScrollView);
if (ta != null) {
mHeaderHeight = (int) ta.getDimension(R.styleable.PullScrollView_headerHeight, -1);
mHeaderVisibleHeight = (int) ta.getDimension(R.styleable
.PullScrollView_headerVisibleHeight, -1);
ta.recycle();
}
}
}
示例15: RoundImageView
import android.content.res.TypedArray; //导入方法依赖的package包/类
public RoundImageView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
if (Build.VERSION.SDK_INT < 18) {
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
TypedArray array = context.getTheme().obtainStyledAttributes(attrs, R.styleable.RoundImageView, defStyleAttr, 0);
imageRadius = (int) array.getDimension(R.styleable.RoundImageView_imageRadius, 4);
imageRadius = dp2px(context, imageRadius);
imagePosition = array.getInt(R.styleable.RoundImageView_imagePosition, 0);
array.recycle();
}