java font.getfont_Java Ui.getFont方法代码示例

import net.qiujuer.genius.ui.Ui; //导入方法依赖的package包/类

private void initAttrs(Context context, Resources resources, boolean notEdit, AttributeSet attrs, int defStyleAttr, int defStyleRes) {

TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AbsSeekBar,

defStyleAttr, defStyleRes);

// Values

int max = a.getInteger(R.styleable.AbsSeekBar_gMax, mMax);

int min = a.getInteger(R.styleable.AbsSeekBar_gMin, mMin);

int value = a.getInteger(R.styleable.AbsSeekBar_gValue, mValue);

mMin = min;

mMax = Math.max(min + 1, max);

mValue = Math.max(min, Math.min(max, value));

// Colors

ColorStateList trackColor = a.getColorStateList(R.styleable.AbsSeekBar_gTrackColor);

ColorStateList thumbColor = a.getColorStateList(R.styleable.AbsSeekBar_gThumbColor);

ColorStateList scrubberColor = a.getColorStateList(R.styleable.AbsSeekBar_gScrubberColor);

ColorStateList rippleColor = a.getColorStateList(R.styleable.AbsSeekBar_gRippleColor);

ColorStateList indicatorColor = a.getColorStateList(R.styleable.AbsSeekBar_gIndicatorBackgroundColor);

// Size

int tickSize = a.getDimensionPixelSize(R.styleable.AbsSeekBar_gTickSize,

resources.getDimensionPixelSize(R.dimen.genius_seekBar_tickSize));

int thumbSize = a.getDimensionPixelSize(R.styleable.AbsSeekBar_gThumbSize,

resources.getDimensionPixelSize(R.dimen.genius_seekBar_thumbSize));

int touchSize = a.getDimensionPixelSize(R.styleable.AbsSeekBar_gTouchSize,

resources.getDimensionPixelSize(R.dimen.genius_seekBar_touchSize));

int trackStroke = a.getDimensionPixelSize(R.styleable.AbsSeekBar_gTrackStroke,

resources.getDimensionPixelSize(R.dimen.genius_seekBar_trackStroke));

int scrubberStroke = a.getDimensionPixelSize(R.styleable.AbsSeekBar_gScrubberStroke,

resources.getDimensionPixelSize(R.dimen.genius_seekBar_scrubberStroke));

// Other

int indicator = a.getInt(R.styleable.AbsSeekBar_gIndicator, 1);

mMirrorForRtl = a.getBoolean(R.styleable.AbsSeekBar_gMirrorForRtl, mMirrorForRtl);

mAllowTrackClick = a.getBoolean(R.styleable.AbsSeekBar_gAllowTrackClickToDrag, mAllowTrackClick);

mIndicatorFormatter = a.getString(R.styleable.AbsSeekBar_gIndicatorFormatter);

// Indicator TextAppearance

int textAppearanceId = a.getResourceId(R.styleable.AbsSeekBar_gIndicatorTextAppearance, R.style.Genius_Widget_BalloonMarker_TextAppearance);

String fontFile = a.getString(R.styleable.AbsSeekBar_gFont);

a.recycle();

// Set Size

mSeekBarDrawable.setTrackStroke(trackStroke);

mSeekBarDrawable.setScrubberStroke(scrubberStroke);

mSeekBarDrawable.setTouchRadius(touchSize);

mSeekBarDrawable.setTickRadius(tickSize);

mSeekBarDrawable.setThumbRadius(thumbSize);

// Set Colors

if (rippleColor != null)

mRipple.setColorStateList(rippleColor);

if (trackColor != null)

mSeekBarDrawable.setTrackColor(trackColor);

if (thumbColor != null)

mSeekBarDrawable.setThumbColor(thumbColor);

if (scrubberColor != null)

mSeekBarDrawable.setScrubberColor(scrubberColor);

if (notEdit && indicator != 0) {

mIndicator = new PopupIndicator(context);

mIndicator.setListener(mFloaterListener);

if (indicatorColor != null)

mIndicator.setIndicatorColor(indicatorColor);

mIndicator.setIndicatorTextAppearance(textAppearanceId);

mIndicator.setIndicatorClosedSize(thumbSize * 2);

// Font

if (fontFile != null && fontFile.length() > 0) {

Typeface typeface = Ui.getFont(getContext(), fontFile);

if (typeface != null) mIndicator.setTypeface(typeface);

}

}

// Enabled

setEnabled(attrs.getAttributeBooleanValue(Ui.androidStyleNameSpace, "enabled", isEnabled()));

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值