本文整理汇总了Java中android.content.res.TypedArray.getFloat方法的典型用法代码示例。如果您正苦于以下问题:Java TypedArray.getFloat方法的具体用法?Java TypedArray.getFloat怎么用?Java TypedArray.getFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.res.TypedArray
的用法示例。
在下文中一共展示了TypedArray.getFloat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void init(AttributeSet attrs) {
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.LoadingView);
ballLeftColor = a.getColor(R.styleable.LoadingView_left_ball_color, DEFAULT_BALL_COLOR);
ballRightColor = a.getColor(R.styleable.LoadingView_right_ball_color, DEFAULT_BALL_COLOR);
radius = a.getFloat(R.styleable.LoadingView_radius, DEFAULT_RADIUS);
maxTouchDistance = (float) (radius * 2.5);
ballMoveDistance = (float) (radius * 3.5);
animationSpeed = a.getFloat(R.styleable.LoadingView_animation_speed, DEFAULT_SPEED);
isNeedAnimation = a.getBoolean(R.styleable.LoadingView_need_animation, true);
a.recycle();
paint.setColor(ballLeftColor);
paint.setStyle(Paint.Style.FILL);
paint.setAntiAlias(true);
paint2.setColor(ballRightColor);
paint2.setStyle(Paint.Style.FILL);
paint2.setAntiAlias(true);
}
示例2: CircularMusicProgressBar
import android.content.res.TypedArray; //导入方法依赖的package包/类
public CircularMusicProgressBar(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircularMusicProgressBar, defStyle, 0);
mBorderWidth = a.getDimensionPixelSize(R.styleable.CircularMusicProgressBar_border_width, DEFAULT_BORDER_WIDTH);
mBorderColor = a.getColor(R.styleable.CircularMusicProgressBar_border_color, DEFAULT_BORDER_COLOR);
mBorderOverlay = a.getBoolean(R.styleable.CircularMusicProgressBar_border_overlay, DEFAULT_BORDER_OVERLAY);
mDrawAntiClockwise = a.getBoolean(R.styleable.CircularMusicProgressBar_draw_anticlockwise, DEFAULT_DRAW_ANTI_CLOCKWISE);
mFillColor = a.getColor(R.styleable.CircularMusicProgressBar_fill_color, DEFAULT_FILL_COLOR);
mInnrCircleDiammeter = a.getFloat(R.styleable.CircularMusicProgressBar_centercircle_diammterer, DEFAULT_INNTER_DAIMMETER_FRACTION);
mProgressColor = a.getColor(R.styleable.CircularMusicProgressBar_progress_color, DEFAULT_PROGRESS_COLOR);
mBaseStartAngle = a.getFloat(R.styleable.CircularMusicProgressBar_progress_startAngle, 0);
a.recycle();
init();
}
示例3: applyAttrs
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void applyAttrs(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Gauge, 0, 0);
totalNicks = a.getInt(R.styleable.Gauge_totalNicks, totalNicks);
degreesPerNick = 360.0f / totalNicks;
valuePerNick = a.getFloat(R.styleable.Gauge_valuePerNick, valuePerNick);
majorNickInterval = a.getInt(R.styleable.Gauge_majorNickInterval, 10);
minValue = a.getFloat(R.styleable.Gauge_minValue, minValue);
maxValue = a.getFloat(R.styleable.Gauge_maxValue, maxValue);
intScale = a.getBoolean(R.styleable.Gauge_intScale, intScale);
initialValue = a.getFloat(R.styleable.Gauge_initialValue, initialValue);
requestedLabelTextSize = a.getFloat(R.styleable.Gauge_labelTextSize, requestedLabelTextSize);
faceColor = a.getColor(R.styleable.Gauge_faceColor, Color.argb(0xff, 0xff, 0xff, 0xff));
scaleColor = a.getColor(R.styleable.Gauge_scaleColor, 0x9f004d0f);
needleColor = a.getColor(R.styleable.Gauge_needleColor, Color.RED);
needleShadow = a.getBoolean(R.styleable.Gauge_needleShadow, needleShadow);
requestedTextSize = a.getFloat(R.styleable.Gauge_textSize, requestedTextSize);
upperText = a.getString(R.styleable.Gauge_upperText) == null ? upperText : fromHtml(a.getString(R.styleable.Gauge_upperText)).toString();
lowerText = a.getString(R.styleable.Gauge_lowerText) == null ? lowerText : fromHtml(a.getString(R.styleable.Gauge_lowerText)).toString();
a.recycle();
}
示例4: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void init(AttributeSet attrs) {
TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ExpandableTextView);
mMaxCollapsedLines = typedArray.getInt(R.styleable.ExpandableTextView_maxCollapsedLines, MAX_COLLAPSED_LINES);
mAnimationDuration = typedArray.getInt(R.styleable.ExpandableTextView_animDuration, DEFAULT_ANIM_DURATION);
mAnimAlphaStart = typedArray.getFloat(R.styleable.ExpandableTextView_animAlphaStart, DEFAULT_ANIM_ALPHA_START);
mExpandText = typedArray.getString(R.styleable.ExpandableTextView_expandText);
mCollapseText = typedArray.getString(R.styleable.ExpandableTextView_collapseText);
if (mExpandText == null) {
mExpandText = EXPAND_BUTTON_TEXT;
}
if (mCollapseText == null) {
mCollapseText = COLLAPS_BUTTON_TEXT;
}
typedArray.recycle();
// enforces vertical orientation
setOrientation(LinearLayout.VERTICAL);
// default visibility is gone
setVisibility(GONE);
}
示例5: 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);
}
示例6: SimpleViewBehavior
import android.content.res.TypedArray; //导入方法依赖的package包/类
public SimpleViewBehavior(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SimpleViewBehavior);
mDependViewId = a.getResourceId(R.styleable.SimpleViewBehavior_svb_dependOn, mDependViewId);
mDependType = a.getInt(R.styleable.SimpleViewBehavior_svb_dependType, mDependType);
mDependTargetX = a.getDimensionPixelOffset(R.styleable.SimpleViewBehavior_svb_dependTargetX, UNSPECIFIED_INT);
mDependTargetY = a.getDimensionPixelOffset(R.styleable.SimpleViewBehavior_svb_dependTargetY, UNSPECIFIED_INT);
mDependTargetWidth = a.getDimensionPixelOffset(R.styleable.SimpleViewBehavior_svb_dependTargetWidth, UNSPECIFIED_INT);
mDependTargetHeight = a.getDimensionPixelOffset(R.styleable.SimpleViewBehavior_svb_dependTargetHeight, UNSPECIFIED_INT);
targetX = a.getDimensionPixelOffset(R.styleable.SimpleViewBehavior_svb_targetX, UNSPECIFIED_INT);
targetY = a.getDimensionPixelOffset(R.styleable.SimpleViewBehavior_svb_targetY, UNSPECIFIED_INT);
targetWidth = a.getDimensionPixelOffset(R.styleable.SimpleViewBehavior_svb_targetWidth, UNSPECIFIED_INT);
targetHeight = a.getDimensionPixelOffset(R.styleable.SimpleViewBehavior_svb_targetHeight, UNSPECIFIED_INT);
targetBackgroundColor = a.getColor(R.styleable.SimpleViewBehavior_svb_targetBackgroundColor, UNSPECIFIED_INT);
targetAlpha = a.getFloat(R.styleable.SimpleViewBehavior_svb_targetAlpha, UNSPECIFIED_FLOAT);
targetRotateX = a.getFloat(R.styleable.SimpleViewBehavior_svb_targetRotateX, UNSPECIFIED_FLOAT);
targetRotateY = a.getFloat(R.styleable.SimpleViewBehavior_svb_targetRotateY, UNSPECIFIED_FLOAT);
mAnimationId = a.getResourceId(R.styleable.SimpleViewBehavior_svb_animation, mAnimationId);
a.recycle();
}
示例7: initAttr
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void initAttr(@Nullable AttributeSet attrs)
{
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.CountDownProgress);
if (a != null)
{
// circleRadius = a.getDimensionPixelOffset(R.styleable.CountDownProgress_cdp_circle_radius, dp2px(17));
circleSolidColor = a.getColor(R.styleable.CountDownProgress_cdp_circle_solid_color, 0xccaaaaaa);
circleStrokeWidth =
a.getDimensionPixelOffset(R.styleable.CountDownProgress_cdp_circle_stroke_width, dp2px(2));
circleColor = a.getColor(R.styleable.CountDownProgress_cdp_circle_stroke_color, 0xffe0e0e0);
progressColor = a.getColor(R.styleable.CountDownProgress_cdp_progress_color, 0xff5e5e5e);
progressWidth =
a.getDimensionPixelOffset(R.styleable.CountDownProgress_cdp_progress_width, circleStrokeWidth);
textColor = a.getColor(R.styleable.CountDownProgress_cdp_text_color, 0xffffffff);
textSize = a.getDimensionPixelSize(R.styleable.CountDownProgress_cdp_text_size, dp2px(14));
text = a.getString(R.styleable.CountDownProgress_cdp_text);
countDownTime = a.getInt(R.styleable.CountDownProgress_cdp_count_down_time, 5000);
startDegree = a.getFloat(R.styleable.CountDownProgress_cdp_start_degree, 270f);
if (TextUtils.isEmpty(text))
text = "跳过";
a.recycle();
}
}
示例8: WheelView
import android.content.res.TypedArray; //导入方法依赖的package包/类
public WheelView(Context context, AttributeSet attrs) {
super(context, attrs);
textSize = getResources().getDimensionPixelSize(R.dimen.view_text_size);//默认大小
DisplayMetrics dm = getResources().getDisplayMetrics();
float density = dm.density; // 屏幕密度(0.75/1.0/1.5/2.0/3.0)
if (density<1){//根据密度不同进行适配
centerContentOffset=2.4F;
}else if (1<=density&&density<2){
centerContentOffset = 3.6F;
}else if (1<=density&&density<2){
centerContentOffset = 4.5F;
}else if (2<=density&&density<3){
centerContentOffset = 6.0F;
}else if (density>=3){
centerContentOffset= density * 2.5F;
}
if (attrs != null) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LoopView, 0, 0);
mGravity = a.getInt(R.styleable.LoopView_view_gravity, Gravity.CENTER);
textColorOut = a.getColor(R.styleable.LoopView_topBottomTextColor, textColorOut);
textColorCenter = a.getColor(R.styleable.LoopView_centerTextColor, textColorCenter);
dividerColor = a.getColor(R.styleable.LoopView_lineColor, dividerColor);
textSize = a.getDimensionPixelOffset(R.styleable.LoopView_textSize, textSize);
lineSpacingMultiplier = a.getFloat(R.styleable.LoopView_lineSpacingMultiplier, lineSpacingMultiplier);
a.recycle();//回收内存
}
judgeLineSpae();
initLoopView(context);
}
示例9: initAttrs
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void initAttrs(Context context, AttributeSet attrs, int defStyle) {
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RecyclerViewPager, defStyle,
0);
mFlingFactor = a.getFloat(R.styleable.RecyclerViewPager_rvp_flingFactor, 0.15f);
mTriggerOffset = a.getFloat(R.styleable.RecyclerViewPager_rvp_triggerOffset, 0.25f);
mSinglePageFling = a.getBoolean(R.styleable.RecyclerViewPager_rvp_singlePageFling, mSinglePageFling);
isInertia = a.getBoolean(R.styleable.RecyclerViewPager_rvp_inertia, false);
mMillisecondsPerInch = a.getFloat(R.styleable.RecyclerViewPager_rvp_millisecondsPerInch, 25f);
a.recycle();
}
示例10: ArcLayout
import android.content.res.TypedArray; //导入方法依赖的package包/类
public ArcLayout(Context context, AttributeSet attrs) {
super(context, attrs);
if (attrs != null) {
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.ArcLayout, 0, 0);
mFromDegrees = a.getFloat(R.styleable.ArcLayout_fromDegrees, DEFAULT_FROM_DEGREES);
mToDegrees = a.getFloat(R.styleable.ArcLayout_toDegrees, DEFAULT_TO_DEGREES);
mChildSize = Math.max(a.getDimensionPixelSize(R.styleable.ArcLayout_childSize, 0), 0);
a.recycle();
}
}
示例11: GradientProgressBar
import android.content.res.TypedArray; //导入方法依赖的package包/类
public GradientProgressBar(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.GradientProgressBar);
radius = a.getFloat(R.styleable.GradientProgressBar_pp_round_radius, 0f);
maxProgress = a.getFloat(R.styleable.GradientProgressBar_pp_max_progress, 100f);
currentProgress = a.getFloat(R.styleable.GradientProgressBar_pp_current_progress, 0f);
isRoundRect = a.getBoolean(R.styleable.GradientProgressBar_pp_is_round, true);
a.recycle();
init();
}
示例12: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs) {
TypedArray typedArray = context
.obtainStyledAttributes(attrs, R.styleable.CircularLayoutAttrs);
int capacity = typedArray.getInteger(R.styleable.CircularLayoutAttrs_capacity, 0);
if (capacity != 0) {
setCapacity(capacity);
}
/*angle attr always wins*/
float angle = typedArray.getFloat(R.styleable.CircularLayoutAttrs_angle, (float) BAD_ANGLE);
if (angle != BAD_ANGLE) {
setAngle(angle);
}
typedArray.recycle();
}
示例13: populateAttributes
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void populateAttributes(Context context, AttributeSet attrs) {
primaryColor = MiscUtils.getColor(getContext(), R.attr.colorPrimary);
screenWidth = MiscUtils.getScreenWidth(getContext());
tenDp = MiscUtils.dpToPixel(getContext(), 10);
maxFixedItemWidth = MiscUtils.dpToPixel(getContext(), 168);
TypedArray ta = context.getTheme().obtainStyledAttributes(
attrs, R.styleable.BottomBar, 0, 0);
try {
tabXmlResource = ta.getResourceId(R.styleable.BottomBar_bb_tabXmlResource, 0);
isTabletMode = ta.getBoolean(R.styleable.BottomBar_bb_tabletMode, false);
behaviors = ta.getInteger(R.styleable.BottomBar_bb_behavior, BEHAVIOR_NONE);
inActiveTabAlpha = ta.getFloat(R.styleable.BottomBar_bb_inActiveTabAlpha,
isShiftingMode() ? DEFAULT_INACTIVE_SHIFTING_TAB_ALPHA : 1);
activeTabAlpha = ta.getFloat(R.styleable.BottomBar_bb_activeTabAlpha, 1);
@ColorInt
int defaultInActiveColor = isShiftingMode() ?
Color.WHITE : ContextCompat.getColor(context, R.color.bb_inActiveBottomBarItemColor);
int defaultActiveColor = isShiftingMode() ? Color.WHITE : primaryColor;
inActiveTabColor = ta.getColor(R.styleable.BottomBar_bb_inActiveTabColor, defaultInActiveColor);
activeTabColor = ta.getColor(R.styleable.BottomBar_bb_activeTabColor, defaultActiveColor);
badgeBackgroundColor = ta.getColor(R.styleable.BottomBar_bb_badgeBackgroundColor, Color.RED);
titleTextAppearance = ta.getResourceId(R.styleable.BottomBar_bb_titleTextAppearance, 0);
titleTypeFace = getTypeFaceFromAsset(ta.getString(R.styleable.BottomBar_bb_titleTypeFace));
showShadow = ta.getBoolean(R.styleable.BottomBar_bb_showShadow, true);
} finally {
ta.recycle();
}
}
示例14: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void init(AttributeSet attrs) {
TypedArray typedArray = getContext().obtainStyledAttributes(
attrs,
R.styleable.RatioRelativeLayout);
fixedAttribute = FixedAttribute.fromId(typedArray.getInt(R.styleable.RatioRelativeLayout_fixed_attribute, 0));
horizontalRatio = typedArray.getFloat(R.styleable.RatioRelativeLayout_horizontal_ratio, 1);
verticalRatio = typedArray.getFloat(R.styleable.RatioRelativeLayout_vertical_ratio, 1);
typedArray.recycle();
}
示例15: CircleImage
import android.content.res.TypedArray; //导入方法依赖的package包/类
public CircleImage(Context context, AttributeSet attrs, int i) {
super(context, attrs, i);
this.context = context;
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleImage, i, 0);
borderWidth = a.getDimensionPixelSize(R.styleable.CircleImage_border_width, 0);
color = a.getColor(R.styleable.CircleImage_border_color, Color.WHITE);
addShadow = a.getBoolean(R.styleable.CircleImage_add_shadow, false);
shadowColor = a.getColor(R.styleable.CircleImage_shadow_color, Color.BLACK);
shadowRadius = a.getFloat(R.styleable.CircleImage_shadow_radius, DEFAULT_SHADOW_RADIUS);
a.recycle();
setup();
}