本文整理汇总了Java中android.content.res.TypedArray.getInteger方法的典型用法代码示例。如果您正苦于以下问题:Java TypedArray.getInteger方法的具体用法?Java TypedArray.getInteger怎么用?Java TypedArray.getInteger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.res.TypedArray
的用法示例。
在下文中一共展示了TypedArray.getInteger方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SwipeSectorLayout
import android.content.res.TypedArray; //导入方法依赖的package包/类
public SwipeSectorLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray ta = context.obtainStyledAttributes(attrs,
R.styleable.SwipeSectorLayout, 0, 0);
int degree = ta.getInteger(R.styleable.SwipeSectorLayout_degree, 90);
if(degree < 20){
throw new IllegalStateException("degree attribute cannot be less than 20");
} else if (degree > 180){
throw new IllegalStateException("degree attribute cannot be greater than 180");
}
mDegreeUnit = degree / 2;
mItemViewWidth = ta.getDimensionPixelSize(R.styleable.SwipeSectorLayout_item_width, 200);
ta.recycle();
mContext = context;
addViews();
setChildrenDrawingOrderEnabled(true);
if(isInEditMode())
setPreviewColor(true);
}
示例2: MaterialProgressBar
import android.content.res.TypedArray; //导入方法依赖的package包/类
public MaterialProgressBar(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
if (isInEditMode()) {
setIndeterminateDrawable(new MaterialProgressDrawable(getContext(), this));
return;
}
Resources res = context.getResources();
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MaterialProgressBar, defStyle, 0);
final int color = a.getColor(R.styleable.MaterialProgressBar_color, res.getColor(R.color.accentColor));
final float strokeWidth = a.getDimension(R.styleable.MaterialProgressBar_stroke_width, res.getDimension(R.dimen.default_stroke_width));
final float sweepSpeed = a.getFloat(R.styleable.MaterialProgressBar_sweep_speed, Float.parseFloat(res.getString(R.string.default_sweep_speed)));
final float rotationSpeed = a.getFloat(R.styleable.MaterialProgressBar_rotation_speed, Float.parseFloat(res.getString(R.string.default_rotation_speed)));
final int minSweepAngle = a.getInteger(R.styleable.MaterialProgressBar_min_sweep_angle, res.getInteger(R.integer.default_min_sweep_angle));
final int maxSweepAngle = a.getInteger(R.styleable.MaterialProgressBar_max_sweep_angle, res.getInteger(R.integer.default_max_sweep_angle));
a.recycle();
indeterminateDrawable = new MaterialProgressDrawable(getContext(), this);
indeterminateDrawable.setBackgroundColor(CIRCLE_BG_LIGHT);
indeterminateDrawable.setAlpha(255);
indeterminateDrawable.updateSizes(MaterialProgressDrawable.LARGE);
setColor(color);
}
示例3: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void init(AttributeSet attrs) {
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.RippleView, 0, 0);
mStrokeWidth = a.getDimension(R.styleable.RippleView_stroke_width, 1);
mDuration = a.getInteger(R.styleable.RippleView_ripple_duration, 4000);
mRepeatCount = a.getInteger(R.styleable.RippleView_repeat_count, -1);
circleNum = a.getInteger(R.styleable.RippleView_circle_num, 3);
maxRadiusMultiple = a.getFloat(R.styleable.RippleView_max_radius_multiple, 1.4f);
color = a.getColor(R.styleable.RippleView_circle_color, Color.WHITE);
a.recycle();
}
示例4: WeekDatePicker
import android.content.res.TypedArray; //导入方法依赖的package包/类
public WeekDatePicker(Context context, AttributeSet attrs) {
super(context, attrs);
int selected = 0;
TypedArray array = context.obtainStyledAttributes(attrs,R.styleable.WeekPickerAttrs);
if(array != null) {
selected = array.getInteger(R.styleable.WeekPickerAttrs_isSelected, 0);
array.recycle();
}
initWithSelected(context,selected);
}
示例5: LineColorPicker
import android.content.res.TypedArray; //导入方法依赖的package包/类
public LineColorPicker(Context context, AttributeSet attrs) {
super(context, attrs);
paint = new Paint();
paint.setStyle(Style.FILL);
final TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.LineColorPicker, 0, 0);
try {
mOrientation = a.getInteger(R.styleable.LineColorPicker_orientation, HORIZONTAL);
if (!isInEditMode()) {
final int colorsArrayResId = a.getResourceId(R.styleable.LineColorPicker_colors, -1);
if (colorsArrayResId > 0) {
final int[] colors = context.getResources().getIntArray(colorsArrayResId);
setColors(colors);
}
}
final int selected = a.getInteger(R.styleable.LineColorPicker_selectedColorIndex, -1);
if (selected != -1) {
final int[] currentColors = getColors();
final int currentColorsLength = currentColors != null ? currentColors.length : 0;
if (selected < currentColorsLength) {
setSelectedColorPosition(selected);
}
}
} finally {
a.recycle();
}
}
示例6: resolveInteger
import android.content.res.TypedArray; //导入方法依赖的package包/类
public static int resolveInteger(Context context, @AttrRes int attr, int fallback) {
TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{attr});
int defValue = 0;
if (fallback != 0) {
defValue = context.getResources().getInteger(fallback);
}
try {
return a.getInteger(0, defValue);
} finally {
a.recycle();
}
}
示例7: LayoutParams
import android.content.res.TypedArray; //导入方法依赖的package包/类
public LayoutParams(Context context, AttributeSet attrs) {
super(context, attrs);
final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
gravity = a.getInteger(0, Gravity.TOP);
a.recycle();
}
示例8: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs, int defStyleAttr){
mContext = context;
mMinumWidth = dp2px(48);
mMinumHeight = dp2px(48);
TypedArray attributes = mContext.obtainStyledAttributes(attrs, R.styleable.WaveLoadingView, defStyleAttr, 0);
mType = attributes.getInteger(R.styleable.WaveLoadingView_wlv_shapeType, DEFAULT_WAVE_SHAPE);
mWaveColor = attributes.getInteger(R.styleable.WaveLoadingView_wlv_waveColor, DEFAULT_WAVE_COLOR);
//最后范围1~2个宽度
float lengthRatio = attributes.getFloat(R.styleable.WaveLoadingView_wlv_waveLengthRation, DEFAULT_WAVE_LENGTH_RATIO);
mWaveLengthRatio = 1.0f + 1.0f * (lengthRatio > 1.0f ? 1.0f : lengthRatio);
//最后范围0.1~0.4个高度
float ampRatio = attributes.getFloat(R.styleable.WaveLoadingView_wlv_waveAmplitudeRatio, DEFAULT_AMPLITUDE_RATIO);
mWaveAmplitudeRatio = 0.5f + 0.5f * (ampRatio > 1.0f ? 1.0f : ampRatio);
mBorderPaint = new Paint();
mBorderPaint.setAntiAlias(true);
mBorderPaint.setStyle(Paint.Style.STROKE);
mBorderPaint.setStrokeWidth(dp2px(2));
//mBgPaint = new Paint();
mWavePaint = new Paint();
mWavePaint.setAntiAlias(true);
mWaveShaderMatrix = new Matrix();
mTitlePaint = new Paint();
mTitlePaint.setColor(DEFAULT_TITLE_COLOR);
mTitlePaint.setStyle(Paint.Style.FILL);
mTitlePaint.setAntiAlias(true);
mTitlePaint.setTextSize(DEFAULT_TITLE_CENTER_SIZE);
initBasicTravelAnimation();
attributes.recycle();
}
示例9: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
public void init(@Nullable AttributeSet set){
resources = new int[noOfTabs];
mRect = new RectF();
mRect.left = 0;
mRect.top = 0;
mRect.bottom = 140;
triangle = new Path();
leftpt=new PointF();
midpt=new PointF();
rightpt=new PointF();
mRectPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mRectPaint.setStyle(Paint.Style.FILL);
mCirclePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mCirclePaint.setColor(Color.GREEN);
if(set == null)
{
return;
}
TypedArray ta = getContext().obtainStyledAttributes(set,R.styleable.IndicatorView);
noOfTabs = ta.getInteger(R.styleable.IndicatorView_no_of_sections,3);
sectionColour = ta.getColor(R.styleable.IndicatorView_set_colour,Color.YELLOW);
mRectPaint.setColor(sectionColour);
mCirclePaint.setColor(Color.WHITE);
imgRes = new Bitmap[noOfTabs];
vds = new VectorDrawableCompat[noOfTabs];
ta.recycle();
}
示例10: SwitchIconView
import android.content.res.TypedArray; //导入方法依赖的package包/类
public SwitchIconView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray array = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.SwitchIconView, 0, 0);
try {
iconTintColor = array.getColor(R.styleable.SwitchIconView_si_tint_color, Color.BLACK);
animationDuration = array.getInteger(R.styleable.SwitchIconView_si_animation_duration, DEFAULT_ANIMATION_DURATION);
disabledStateAlpha = array.getFloat(R.styleable.SwitchIconView_si_disabled_alpha, DEFAULT_DISABLED_ALPHA);
disabledStateColor = array.getColor(R.styleable.SwitchIconView_si_disabled_color, iconTintColor);
enabled = array.getBoolean(R.styleable.SwitchIconView_si_enabled, true);
noDash = array.getBoolean(R.styleable.SwitchIconView_si_no_dash, false);
} finally {
array.recycle();
}
if (disabledStateAlpha < 0f || disabledStateAlpha > 1f) {
throw new IllegalArgumentException("Wrong value for si_disabled_alpha [" + disabledStateAlpha + "]. "
+ "Must be value from range [0, 1]");
}
colorFilter = new PorterDuffColorFilter(iconTintColor, PorterDuff.Mode.SRC_IN);
setColorFilter(colorFilter);
dashXStart = getPaddingLeft();
dashYStart = getPaddingTop();
dashPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
dashPaint.setStyle(Paint.Style.STROKE);
dashPaint.setColor(iconTintColor);
clipPath = new Path();
initDashCoordinates();
setFraction(enabled ? 0f : 1f);
}
示例11: MaterialRippleLayout
import android.content.res.TypedArray; //导入方法依赖的package包/类
public MaterialRippleLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
setWillNotDraw(false);
gestureDetector = new GestureDetector(context, longClickListener);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MaterialRippleLayout);
rippleColor = a.getColor(R.styleable.MaterialRippleLayout_mrl_rippleColor, DEFAULT_COLOR);
rippleDiameter = a.getDimensionPixelSize(
R.styleable.MaterialRippleLayout_mrl_rippleDimension,
(int) dpToPx(getResources(), DEFAULT_DIAMETER_DP)
);
rippleOverlay = a.getBoolean(R.styleable.MaterialRippleLayout_mrl_rippleOverlay, DEFAULT_RIPPLE_OVERLAY);
rippleHover = a.getBoolean(R.styleable.MaterialRippleLayout_mrl_rippleHover, DEFAULT_HOVER);
rippleDuration = a.getInt(R.styleable.MaterialRippleLayout_mrl_rippleDuration, DEFAULT_DURATION);
rippleAlpha = (int) (255 * a.getFloat(R.styleable.MaterialRippleLayout_mrl_rippleAlpha, DEFAULT_ALPHA));
rippleDelayClick = a.getBoolean(R.styleable.MaterialRippleLayout_mrl_rippleDelayClick, DEFAULT_DELAY_CLICK);
rippleFadeDuration = a.getInteger(R.styleable.MaterialRippleLayout_mrl_rippleFadeDuration, DEFAULT_FADE_DURATION);
rippleBackground = new ColorDrawable(a.getColor(R.styleable.MaterialRippleLayout_mrl_rippleBackground, DEFAULT_BACKGROUND));
ripplePersistent = a.getBoolean(R.styleable.MaterialRippleLayout_mrl_ripplePersistent, DEFAULT_PERSISTENT);
rippleInAdapter = a.getBoolean(R.styleable.MaterialRippleLayout_mrl_rippleInAdapter, DEFAULT_SEARCH_ADAPTER);
rippleRoundedCorners = a.getDimensionPixelSize(R.styleable.MaterialRippleLayout_mrl_rippleRoundedCorners, DEFAULT_ROUNDED_CORNERS);
a.recycle();
paint.setColor(rippleColor);
paint.setAlpha(rippleAlpha);
enableClipPathSupportIfNecessary();
}
示例12: ShadowLayout
import android.content.res.TypedArray; //导入方法依赖的package包/类
public ShadowLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray a = context.getTheme().obtainStyledAttributes(
attrs,
R.styleable.ShadowLayout,
0, 0);
try {
mShadowDx = a.getDimensionPixelSize(R.styleable.ShadowLayout_skShadowDx, DEFAULT_SHADOW_DX);
mShadowDy = a.getDimensionPixelSize(R.styleable.ShadowLayout_skShadowDy, DEFAULT_SHADOW_DY);
mShadowColor = a.getColor(R.styleable.ShadowLayout_skShadowColor, DEFAULT_SHADOW_COLOR);
mShadowAlpha = a.getFloat(R.styleable.ShadowLayout_skShadowAlpha, DEFAULT_SHADOW_ALPHA);
mShadowRadius = a.getInteger(R.styleable.ShadowLayout_skShadowRadius, DEFAULT_SHADOW_RADIUS);
mShadowScale = a.getFloat(R.styleable.ShadowLayout_skShadowScale, DEFAULT_SHADOW_SCALE);
mReuseKey = a.getString(R.styleable.ShadowLayout_skReuseKey);
} finally {
a.recycle();
}
mImageView = new ImageView(context);
mImageView.setLayoutParams(new FrameLayout.LayoutParams(0, 0));
mImageView.setScaleType(ImageView.ScaleType.FIT_XY);
addView(mImageView);
setShadowDx(mShadowDx);
setShadowDy(mShadowDy);
setShadowColor(mShadowColor);
setShadowAlpha(mShadowAlpha);
setShadowRadius(mShadowRadius);
setShadowScale(mShadowScale);
getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
getViewTreeObserver().removeOnGlobalLayoutListener(this);
refresh();
}
});
}
示例13: initValue
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void initValue(Context context, AttributeSet attrs) {
TypedArray ta = context.obtainStyledAttributes(attrs,
R.styleable.TextViewExpandableAnimation);
expandLines = ta.getInteger(
R.styleable.TextViewExpandableAnimation_tvea_expandLines, 5);
drawableShrink = ta
.getDrawable(R.styleable.TextViewExpandableAnimation_tvea_shrinkBitmap);
drawableExpand = ta
.getDrawable(R.styleable.TextViewExpandableAnimation_tvea_expandBitmap);
textViewStateColor = ta.getColor(R.styleable.TextViewExpandableAnimation_tvea_textStateColor, ContextCompat.getColor(context, R.color.colorPrimary));
textShrink = ta.getString(R.styleable.TextViewExpandableAnimation_tvea_textShrink);
textExpand = ta.getString(R.styleable.TextViewExpandableAnimation_tvea_textExpand);
if (null == drawableShrink) {
drawableShrink = ContextCompat.getDrawable(context, R.drawable.icon_green_arrow_up);
}
if (null == drawableExpand) {
drawableExpand = ContextCompat.getDrawable(context, R.drawable.icon_green_arrow_down);
}
if (TextUtils.isEmpty(textShrink)) {
textShrink = context.getString(R.string.shrink);
}
if (TextUtils.isEmpty(textExpand)) {
textExpand = context.getString(R.string.expand);
}
textContentColor = ta.getColor(R.styleable.TextViewExpandableAnimation_tvea_textContentColor, ContextCompat.getColor(context, R.color.colorTabText));
textContentSize = ta.getDimension(R.styleable.TextViewExpandableAnimation_tvea_textContentSize, 14);
ta.recycle();
}
示例14: ViewPagerIndicator
import android.content.res.TypedArray; //导入方法依赖的package包/类
public ViewPagerIndicator(Context context, AttributeSet attrs, int defStyle)
{
super(context, attrs, defStyle);
final int density = (int) context.getResources().getDisplayMetrics().density;
final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.InkPageIndicator, defStyle, 0);
dotDiameter = a.getDimensionPixelSize(R.styleable.InkPageIndicator_dotDiameter, DEFAULT_DOT_SIZE * density);
dotRadius = dotDiameter / 2;
halfDotRadius = dotRadius / 2;
gap = a.getDimensionPixelSize(R.styleable.InkPageIndicator_dotGap, DEFAULT_GAP * density);
animDuration = (long)a.getInteger(R.styleable.InkPageIndicator_animationDuration, DEFAULT_ANIM_DURATION);
animHalfDuration = animDuration / 2;
unselectedColour = a.getColor(R.styleable.InkPageIndicator_pageIndicatorColor, DEFAULT_UNSELECTED_COLOUR);
selectedColour = a.getColor(R.styleable.InkPageIndicator_currentPageIndicatorColor, DEFAULT_SELECTED_COLOUR);
a.recycle();
unselectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
unselectedPaint.setColor(unselectedColour);
selectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
selectedPaint.setColor(selectedColour);
interpolator = AnimUtils.getFastOutSlowInInterpolator(context);
combinedUnselectedPath = new Path();
unselectedDotPath = new Path();
unselectedDotLeftPath = new Path();
unselectedDotRightPath = new Path();
rectF = new RectF();
addOnAttachStateChangeListener(this);
}
示例15: initAttrs
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void initAttrs(Context context, AttributeSet attrs) {
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.WoWoViewPager, 0, 0);
if (typedArray == null) return;
try {
gearbox = WoWoGearbox.Gearboxes[typedArray.getInteger(R.styleable.WoWoViewPager_wowo_gearbox, context.getResources().getInteger(R.integer.default_gearbox))];
draggable = typedArray.getBoolean(R.styleable.WoWoViewPager_wowo_draggable, context.getResources().getBoolean(R.bool.default_draggable));
scrollDuration = typedArray.getInteger(R.styleable.WoWoViewPager_wowo_scrollDuration, context.getResources().getInteger(R.integer.default_scrollDuration));
direction = typedArray.getInteger(R.styleable.WoWoViewPager_wowo_direction, context.getResources().getInteger(R.integer.default_direction));
} finally {
typedArray.recycle();
}
}