本文整理汇总了Java中android.content.res.TypedArray.getFraction方法的典型用法代码示例。如果您正苦于以下问题:Java TypedArray.getFraction方法的具体用法?Java TypedArray.getFraction怎么用?Java TypedArray.getFraction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.res.TypedArray
的用法示例。
在下文中一共展示了TypedArray.getFraction方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getKeyX
import android.content.res.TypedArray; //导入方法依赖的package包/类
public float getKeyX(final TypedArray keyAttr) {
if (keyAttr == null || !keyAttr.hasValue(R.styleable.Keyboard_Key_keyXPos)) {
return mCurrentX;
}
final float keyXPos = keyAttr.getFraction(R.styleable.Keyboard_Key_keyXPos,
mParams.mBaseWidth, mParams.mBaseWidth, 0);
if (keyXPos >= 0) {
return keyXPos + mParams.mLeftPadding;
}
// If keyXPos is negative, the actual x-coordinate will be
// keyboardWidth + keyXPos.
// keyXPos shouldn't be less than mCurrentX because drawable area for this
// key starts at mCurrentX. Or, this key will overlaps the adjacent key on
// its left hand side.
final int keyboardRightEdge = mParams.mOccupiedWidth - mParams.mRightPadding;
return Math.max(keyXPos + keyboardRightEdge, mCurrentX);
}
示例2: getKeyWidth
import android.content.res.TypedArray; //导入方法依赖的package包/类
public float getKeyWidth(final TypedArray keyAttr, final float keyXPos) {
if (keyAttr == null) {
return getDefaultKeyWidth();
}
final int widthType = ResourceUtils.getEnumValue(keyAttr,
R.styleable.Keyboard_Key_keyWidth, KEYWIDTH_NOT_ENUM);
switch (widthType) {
case KEYWIDTH_FILL_RIGHT:
// If keyWidth is fillRight, the actual key width will be determined to fill
// out the area up to the right edge of the keyboard.
final int keyboardRightEdge = mParams.mOccupiedWidth - mParams.mRightPadding;
return keyboardRightEdge - keyXPos;
default: // KEYWIDTH_NOT_ENUM
return keyAttr.getFraction(R.styleable.Keyboard_Key_keyWidth,
mParams.mBaseWidth, mParams.mBaseWidth, getDefaultKeyWidth());
}
}
示例3: LayoutParams
import android.content.res.TypedArray; //导入方法依赖的package包/类
public LayoutParams(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context
.obtainStyledAttributes(attrs, R.styleable.FlexboxLayout_Layout);
order = a.getInt(R.styleable.FlexboxLayout_Layout_layout_order, ORDER_DEFAULT);
flexGrow = a
.getFloat(R.styleable.FlexboxLayout_Layout_layout_flexGrow, FLEX_GROW_DEFAULT);
flexShrink = a.getFloat(R.styleable.FlexboxLayout_Layout_layout_flexShrink,
FLEX_SHRINK_DEFAULT);
alignSelf = a
.getInt(R.styleable.FlexboxLayout_Layout_layout_alignSelf, ALIGN_SELF_AUTO);
flexBasisPercent = a
.getFraction(R.styleable.FlexboxLayout_Layout_layout_flexBasisPercent, 1, 1,
FLEX_BASIS_PERCENT_DEFAULT);
minWidth = a.getDimensionPixelSize(R.styleable.FlexboxLayout_Layout_layout_minWidth, 0);
minHeight = a
.getDimensionPixelSize(R.styleable.FlexboxLayout_Layout_layout_minHeight, 0);
maxWidth = a.getDimensionPixelSize(R.styleable.FlexboxLayout_Layout_layout_maxWidth,
MAX_SIZE);
maxHeight = a.getDimensionPixelSize(R.styleable.FlexboxLayout_Layout_layout_maxHeight,
MAX_SIZE);
wrapBefore = a.getBoolean(R.styleable.FlexboxLayout_Layout_layout_wrapBefore, false);
a.recycle();
}
示例4: parseAttributes
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void parseAttributes(@NonNull Context context, @Nullable AttributeSet attrs) {
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.TypingIndicatorView, 0, 0);
int animationOrder;
try {
dotSize = a.getDimensionPixelOffset(R.styleable.TypingIndicatorView_dotSize, DOT_SIZE_DEF_VALUE);
numOfDots = a.getInteger(R.styleable.TypingIndicatorView_dotCount, DOT_COUNT_DEF_VALUE);
dotHorizontalSpacing = a.getDimensionPixelOffset(R.styleable.TypingIndicatorView_dotHorizontalSpacing, DOT_HORIZONTAL_SPACING_DEF_VALUE);
dotColor = a.getColor(R.styleable.TypingIndicatorView_dotColor, DOT_COLOR_DEF_VALUE);
dotSecondColor = a.getColor(R.styleable.TypingIndicatorView_dotSecondColor, dotColor);
dotMaxCompressRatio = a.getFraction(R.styleable.TypingIndicatorView_dotMaxCompressRatio, 1, 1, DOT_MAX_COMPRESS_RATIO_DEF_VALUE);
dotAnimationDuration = a.getInteger(R.styleable.TypingIndicatorView_dotAnimationDuration, DOT_ANIMATION_DURATION_DEF_VALUE);
dotAnimationType = a.getInteger(R.styleable.TypingIndicatorView_dotAnimationType, DOT_ANIMATION_TYPE_DEF_VALUE);
isShowBackground = a.getBoolean(R.styleable.TypingIndicatorView_showBackground, false);
backgroundType = a.getInteger(R.styleable.TypingIndicatorView_backgroundType, BACKGROUND_TYPE_DEF_VALUE);
backgroundColor = a.getColor(R.styleable.TypingIndicatorView_backgroundColor, BACKGROUND_COLOR_DEF_VALUE);
animationOrder = a.getInteger(R.styleable.TypingIndicatorView_animationOrder, ANIMATE_ORDER_DEF_VALUE);
animateFrequency = a.getInteger(R.styleable.TypingIndicatorView_animateFrequency, Math.max(dotAnimationDuration, ANIMATE_FREQUENCY_DEF_VALUE));
} finally {
a.recycle();
}
if (dotMaxCompressRatio > 1F || dotMaxCompressRatio < 0F) {
throw new IllegalArgumentException("dotMaxCompressRatio must be between 0% and 100%");
}
if (dotAnimationType == AnimationType.DISAPPEAR) {
animationOrder = Order.SEQUENCE;
}
setAnimationOrder(animationOrder);
}
示例5: getFraction
import android.content.res.TypedArray; //导入方法依赖的package包/类
public static float getFraction(final TypedArray a, final int index, final float defValue) {
final TypedValue value = a.peekValue(index);
if (value == null || !isFractionValue(value)) {
return defValue;
}
return a.getFraction(index, 1, 1, defValue);
}
示例6: getDimensionOrFraction
import android.content.res.TypedArray; //导入方法依赖的package包/类
public static float getDimensionOrFraction(final TypedArray a, final int index, final int base,
final float defValue) {
final TypedValue value = a.peekValue(index);
if (value == null) {
return defValue;
}
if (isFractionValue(value)) {
return a.getFraction(index, base, base, defValue);
} else if (isDimensionValue(value)) {
return a.getDimension(index, defValue);
}
return defValue;
}
示例7: RowAttributes
import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
* Parse and create key attributes. This constructor is used to parse Row tag.
*
* @param keyAttr an attributes array of Row tag.
* @param defaultKeyWidth a default key width.
* @param keyboardWidth the keyboard width that is required to calculate keyWidth attribute.
*/
public RowAttributes(final TypedArray keyAttr, final float defaultKeyWidth,
final int keyboardWidth) {
mDefaultKeyWidth = keyAttr.getFraction(R.styleable.Keyboard_Key_keyWidth,
keyboardWidth, keyboardWidth, defaultKeyWidth);
mDefaultKeyLabelFlags = keyAttr.getInt(R.styleable.Keyboard_Key_keyLabelFlags, 0);
mDefaultBackgroundType = keyAttr.getInt(R.styleable.Keyboard_Key_backgroundType,
Key.BACKGROUND_TYPE_NORMAL);
}
示例8: initAttributes
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void initAttributes(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ImageCoverFlowView);
int totalVisibleChildren = a.getInt(
R.styleable.ImageCoverFlowView_visibleImage, 3);
if (totalVisibleChildren % 2 == 0) { // 一屏幕必须是奇数显示
throw new IllegalArgumentException("visible image must be an odd number");
}
VISIBLE_VIEWS = totalVisibleChildren >> 1; // 计算出左右两两边的显示个数
reflectHeightFraction = a.getFraction(
R.styleable.ImageCoverFlowView_reflectionHeight, 100, 0, 0.0f);
if (reflectHeightFraction > 100) {
reflectHeightFraction = 100;
}
reflectHeightFraction /= 100;
reflectGap = a.getDimensionPixelSize(
R.styleable.ImageCoverFlowView_reflectionGap, 0);
mGravity = CoverFlowGravity.values()[a.getInt(
R.styleable.ImageCoverFlowView_coverflowGravity,
CoverFlowGravity.CENTER_VERTICAL.ordinal())];
mLayoutMode = CoverFlowLayoutMode.values()[a.getInt(
R.styleable.ImageCoverFlowView_coverflowLayoutMode,
CoverFlowLayoutMode.WRAP_CONTENT.ordinal())];
a.recycle();
}
示例9: parseKeyboardAttributes
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void parseKeyboardAttributes(final XmlPullParser parser) {
final AttributeSet attr = Xml.asAttributeSet(parser);
final TypedArray keyboardAttr = mContext.obtainStyledAttributes(
attr, R.styleable.Keyboard, R.attr.keyboardStyle, R.style.Keyboard);
final TypedArray keyAttr = mResources.obtainAttributes(attr, R.styleable.Keyboard_Key);
try {
final KeyboardParams params = mParams;
final int height = params.mId.mHeight;
final int width = params.mId.mWidth;
params.mOccupiedHeight = height;
params.mOccupiedWidth = width;
params.mTopPadding = (int)keyboardAttr.getFraction(
R.styleable.Keyboard_keyboardTopPadding, height, height, 0);
params.mBottomPadding = (int)keyboardAttr.getFraction(
R.styleable.Keyboard_keyboardBottomPadding, height, height, 0);
params.mLeftPadding = (int)keyboardAttr.getFraction(
R.styleable.Keyboard_keyboardLeftPadding, width, width, 0);
params.mRightPadding = (int)keyboardAttr.getFraction(
R.styleable.Keyboard_keyboardRightPadding, width, width, 0);
final int baseWidth =
params.mOccupiedWidth - params.mLeftPadding - params.mRightPadding;
params.mBaseWidth = baseWidth;
params.mDefaultKeyWidth = (int)keyAttr.getFraction(R.styleable.Keyboard_Key_keyWidth,
baseWidth, baseWidth, baseWidth / DEFAULT_KEYBOARD_COLUMNS);
params.mHorizontalGap = (int)keyboardAttr.getFraction(
R.styleable.Keyboard_horizontalGap, baseWidth, baseWidth, 0);
// TODO: Fix keyboard geometry calculation clearer. Historically vertical gap between
// rows are determined based on the entire keyboard height including top and bottom
// paddings.
params.mVerticalGap = (int)keyboardAttr.getFraction(
R.styleable.Keyboard_verticalGap, height, height, 0);
final int baseHeight = params.mOccupiedHeight - params.mTopPadding
- params.mBottomPadding + params.mVerticalGap;
params.mBaseHeight = baseHeight;
params.mDefaultRowHeight = (int)ResourceUtils.getDimensionOrFraction(keyboardAttr,
R.styleable.Keyboard_rowHeight, baseHeight, baseHeight / DEFAULT_KEYBOARD_ROWS);
params.mKeyVisualAttributes = KeyVisualAttributes.newInstance(keyAttr);
params.mMoreKeysTemplate = keyboardAttr.getResourceId(
R.styleable.Keyboard_moreKeysTemplate, 0);
params.mMaxMoreKeysKeyboardColumn = keyAttr.getInt(
R.styleable.Keyboard_Key_maxMoreKeysColumn, 5);
params.mThemeId = keyboardAttr.getInt(R.styleable.Keyboard_themeId, 0);
params.mIconsSet.loadIcons(keyboardAttr);
params.mTextsSet.setLocale(params.mId.getLocale(), mContext);
} finally {
keyAttr.recycle();
keyboardAttr.recycle();
}
}
示例10: MainKeyboardView
import android.content.res.TypedArray; //导入方法依赖的package包/类
public MainKeyboardView(final Context context, final AttributeSet attrs, final int defStyle) {
super(context, attrs, defStyle);
final DrawingPreviewPlacerView drawingPreviewPlacerView =
new DrawingPreviewPlacerView(context, attrs);
final TypedArray mainKeyboardViewAttr = context.obtainStyledAttributes(
attrs, R.styleable.MainKeyboardView, defStyle, R.style.MainKeyboardView);
final int ignoreAltCodeKeyTimeout = mainKeyboardViewAttr.getInt(
R.styleable.MainKeyboardView_ignoreAltCodeKeyTimeout, 0);
mTimerHandler = new TimerHandler(this, ignoreAltCodeKeyTimeout);
final float keyHysteresisDistance = mainKeyboardViewAttr.getDimension(
R.styleable.MainKeyboardView_keyHysteresisDistance, 0.0f);
final float keyHysteresisDistanceForSlidingModifier = mainKeyboardViewAttr.getDimension(
R.styleable.MainKeyboardView_keyHysteresisDistanceForSlidingModifier, 0.0f);
mKeyDetector = new KeyDetector(
keyHysteresisDistance, keyHysteresisDistanceForSlidingModifier);
PointerTracker.init(mainKeyboardViewAttr, mTimerHandler, this /* DrawingProxy */);
final boolean hasDistinctMultitouch = context.getPackageManager()
.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT);
mNonDistinctMultitouchHelper = hasDistinctMultitouch ? null
: new NonDistinctMultitouchHelper();
final int backgroundDimAlpha = mainKeyboardViewAttr.getInt(
R.styleable.MainKeyboardView_backgroundDimAlpha, 0);
mBackgroundDimAlphaPaint.setColor(Color.BLACK);
mBackgroundDimAlphaPaint.setAlpha(backgroundDimAlpha);
mLanguageOnSpacebarTextRatio = mainKeyboardViewAttr.getFraction(
R.styleable.MainKeyboardView_languageOnSpacebarTextRatio, 1, 1, 1.0f);
mLanguageOnSpacebarTextColor = mainKeyboardViewAttr.getColor(
R.styleable.MainKeyboardView_languageOnSpacebarTextColor, 0);
mLanguageOnSpacebarTextShadowRadius = mainKeyboardViewAttr.getFloat(
R.styleable.MainKeyboardView_languageOnSpacebarTextShadowRadius,
LANGUAGE_ON_SPACEBAR_TEXT_SHADOW_RADIUS_DISABLED);
mLanguageOnSpacebarTextShadowColor = mainKeyboardViewAttr.getColor(
R.styleable.MainKeyboardView_languageOnSpacebarTextShadowColor, 0);
mLanguageOnSpacebarFinalAlpha = mainKeyboardViewAttr.getInt(
R.styleable.MainKeyboardView_languageOnSpacebarFinalAlpha,
Constants.Color.ALPHA_OPAQUE);
final int languageOnSpacebarFadeoutAnimatorResId = mainKeyboardViewAttr.getResourceId(
R.styleable.MainKeyboardView_languageOnSpacebarFadeoutAnimator, 0);
final int altCodeKeyWhileTypingFadeoutAnimatorResId = mainKeyboardViewAttr.getResourceId(
R.styleable.MainKeyboardView_altCodeKeyWhileTypingFadeoutAnimator, 0);
final int altCodeKeyWhileTypingFadeinAnimatorResId = mainKeyboardViewAttr.getResourceId(
R.styleable.MainKeyboardView_altCodeKeyWhileTypingFadeinAnimator, 0);
mKeyPreviewDrawParams = new KeyPreviewDrawParams(mainKeyboardViewAttr);
mKeyPreviewChoreographer = new KeyPreviewChoreographer(mKeyPreviewDrawParams);
final int moreKeysKeyboardLayoutId = mainKeyboardViewAttr.getResourceId(
R.styleable.MainKeyboardView_moreKeysKeyboardLayout, 0);
final int moreKeysKeyboardForActionLayoutId = mainKeyboardViewAttr.getResourceId(
R.styleable.MainKeyboardView_moreKeysKeyboardForActionLayout,
moreKeysKeyboardLayoutId);
mConfigShowMoreKeysKeyboardAtTouchedPoint = mainKeyboardViewAttr.getBoolean(
R.styleable.MainKeyboardView_showMoreKeysKeyboardAtTouchedPoint, false);
mainKeyboardViewAttr.recycle();
mDrawingPreviewPlacerView = drawingPreviewPlacerView;
final LayoutInflater inflater = LayoutInflater.from(getContext());
mMoreKeysKeyboardContainer = inflater.inflate(moreKeysKeyboardLayoutId, null);
mMoreKeysKeyboardForActionContainer = inflater.inflate(
moreKeysKeyboardForActionLayoutId, null);
mLanguageOnSpacebarFadeoutAnimator = loadObjectAnimator(
languageOnSpacebarFadeoutAnimatorResId, this);
mAltCodeKeyWhileTypingFadeoutAnimator = loadObjectAnimator(
altCodeKeyWhileTypingFadeoutAnimatorResId, this);
mAltCodeKeyWhileTypingFadeinAnimator = loadObjectAnimator(
altCodeKeyWhileTypingFadeinAnimatorResId, this);
mKeyboardActionListener = KeyboardActionListener.EMPTY_LISTENER;
mLanguageOnSpacebarHorizontalMargin = (int)getResources().getDimension(
R.dimen.config_language_on_spacebar_horizontal_margin);
}
示例11: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
* 初始化容器
*/
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
mMainContainer = new FrameLayout(context);
mSubContainer = new FrameLayout(context);
mMainContainer.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ClassifyView, defStyleAttr, R.style.DefaultStyle);
mSubRatio = a.getFraction(R.styleable.ClassifyView_SubRatio, 1, 1, 0.7f);
mMainSpanCount = a.getInt(R.styleable.ClassifyView_MainSpanCount, 3);
mSubSpanCount = a.getInt(R.styleable.ClassifyView_SubSpanCount, 3);
mAnimationDuration = a.getInt(R.styleable.ClassifyView_AnimationDuration, 200);
mEdgeWidth = a.getDimensionPixelSize(R.styleable.ClassifyView_EdgeWidth, 15);
mDragScaleX = a.getFloat(R.styleable.ClassifyView_DragScaleX,1f);
mDragScaleY = a.getFloat(R.styleable.ClassifyView_DragScaleY,1f);
mDragInMergeScaleX = a.getFloat(R.styleable.ClassifyView_DragInMergeScaleX,1f);
mDragInMergeScaleY = a.getFloat(R.styleable.ClassifyView_DragInMergeScaleY,1f);
mGravity = a.getInt(R.styleable.ClassifyView_DragScalePivotGravity,LEFT_TOP);
int mainPadding = a.getDimensionPixelSize(R.styleable.ClassifyView_MainPadding,0);
int mainPaddingLeft = a.getDimensionPixelSize(R.styleable.ClassifyView_MainPaddingLeft,0);
int mainPaddingTop = a.getDimensionPixelSize(R.styleable.ClassifyView_MainPaddingTop,0);
int mainPaddingRight = a.getDimensionPixelSize(R.styleable.ClassifyView_MainPaddingRight,0);
int mainPaddingBottom = a.getDimensionPixelSize(R.styleable.ClassifyView_MainPaddingBottom,0);
boolean mainClipToPadding = a.getBoolean(R.styleable.ClassifyView_MainClipToPadding,true);
int subPadding = a.getDimensionPixelSize(R.styleable.ClassifyView_SubPadding,0);
int subPaddingLeft = a.getDimensionPixelSize(R.styleable.ClassifyView_SubPaddingLeft,0);
int subPaddingTop = a.getDimensionPixelSize(R.styleable.ClassifyView_SubPaddingTop,0);
int subPaddingRight = a.getDimensionPixelSize(R.styleable.ClassifyView_SubPaddingRight,0);
int subPaddingBottom = a.getDimensionPixelSize(R.styleable.ClassifyView_SubPaddingBottom,0);
boolean subClipToPadding = a.getBoolean(R.styleable.ClassifyView_SubClipToPadding,true);
a.recycle();
mMainRecyclerView = getMain(context, attrs);
if(mainPadding != 0){
mMainRecyclerView.setPadding(mainPadding,mainPadding,mainPadding,mainPadding);
}else if(mainPaddingLeft != 0 || mainPaddingTop != 0 || mainPaddingRight != 0 || mainPaddingBottom != 0){
mMainRecyclerView.setPadding(mainPaddingLeft,mainPaddingTop,mainPaddingRight,mainPaddingBottom);
}
mMainRecyclerView.setClipToPadding(mainClipToPadding);
mSubRecyclerView = getSub(context, attrs);
if(subPadding > 0){
mSubRecyclerView.setPadding(subPadding,subPadding,subPadding,subPadding);
}else if(subPaddingLeft != 0 || subPaddingTop != 0 || subPaddingRight != 0 || subPaddingBottom != 0){
mSubRecyclerView.setPadding(subPaddingLeft,subPaddingTop,subPaddingRight,subPaddingBottom);
}
mSubRecyclerView.setClipToPadding(subClipToPadding);
mMainContainer.addView(mMainRecyclerView);
mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
addViewInLayout(mMainContainer, 0, mMainContainer.getLayoutParams());
mDragView = new View(context);
int id = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (id > 0) {
mStatusBarHeight = getResources().getDimensionPixelSize(id);
}
setUpTouchListener(context);
mDragListeners = new ArrayList<>();
}
示例12: extractAttributes
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void extractAttributes(@NonNull final Context context, @Nullable final AttributeSet attrs)
{
if (attrs != null)
{
final TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.SplitPaneLayout);
// misc
this.orientation = array.getInt(R.styleable.SplitPaneLayout_orientation, 0);
this.splitterSize = array.getDimensionPixelSize(R.styleable.SplitPaneLayout_splitterSize, context.getResources().getDimensionPixelSize(R.dimen.spl_default_splitter_size));
this.splitterMovable = array.getBoolean(R.styleable.SplitPaneLayout_splitterMovable, true);
// position
TypedValue value = array.peekValue(R.styleable.SplitPaneLayout_splitterPosition);
if (value != null)
{
if (value.type == TypedValue.TYPE_DIMENSION)
{
this.splitterPosition = array.getDimensionPixelSize(R.styleable.SplitPaneLayout_splitterPosition, Integer.MIN_VALUE);
this.splitterPositionPercent = -1;
}
else if (value.type == TypedValue.TYPE_FRACTION)
{
this.splitterPositionPercent = array.getFraction(R.styleable.SplitPaneLayout_splitterPosition, 100, 100, 50) * 0.01f;
this.splitterPosition = Integer.MIN_VALUE;
}
}
else
{
this.splitterPosition = Integer.MIN_VALUE;
this.splitterPositionPercent = 0.5f;
}
// backgrounds
value = array.peekValue(R.styleable.SplitPaneLayout_splitterBackground);
if (value != null)
{
if (value.type == TypedValue.TYPE_REFERENCE || value.type == TypedValue.TYPE_STRING)
{
this.splitterDrawable = array.getDrawable(R.styleable.SplitPaneLayout_splitterBackground);
}
else if (value.type == TypedValue.TYPE_INT_COLOR_ARGB8 || value.type == TypedValue.TYPE_INT_COLOR_ARGB4 || value.type == TypedValue.TYPE_INT_COLOR_RGB8 || value.type == TypedValue.TYPE_INT_COLOR_RGB4)
{
this.splitterDrawable = new PaintDrawable(array.getColor(R.styleable.SplitPaneLayout_splitterBackground, 0xFF000000));
}
}
value = array.peekValue(R.styleable.SplitPaneLayout_splitterDraggingBackground);
if (value != null)
{
if (value.type == TypedValue.TYPE_REFERENCE || value.type == TypedValue.TYPE_STRING)
{
this.splitterDraggingDrawable = array.getDrawable(R.styleable.SplitPaneLayout_splitterDraggingBackground);
}
else if (value.type == TypedValue.TYPE_INT_COLOR_ARGB8 || value.type == TypedValue.TYPE_INT_COLOR_ARGB4 || value.type == TypedValue.TYPE_INT_COLOR_RGB8 || value.type == TypedValue.TYPE_INT_COLOR_RGB4)
{
this.splitterDraggingDrawable = new PaintDrawable(array.getColor(R.styleable.SplitPaneLayout_splitterDraggingBackground, SPLITTER_DRAG_COLOR));
}
}
else
{
this.splitterDraggingDrawable = new PaintDrawable(SPLITTER_DRAG_COLOR);
}
array.recycle();
}
}
示例13: initAttrs
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void initAttrs(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.UITestAttrsView);
Drawable testDrawable = ta.getDrawable(R.styleable.UITestAttrsView_attr_name_1);
boolean testBool = ta.getBoolean(R.styleable.UITestAttrsView_attr_name_2, false);
int testColor = ta.getColor(R.styleable.UITestAttrsView_attr_name_3, Color.WHITE);
int testDimension = ta.getDimensionPixelSize(R.styleable.UITestAttrsView_attr_name_4, 0);
int testEnum = ta.getInt(R.styleable.UITestAttrsView_attr_name_5, 1);
int testFlag = ta.getInt(R.styleable.UITestAttrsView_attr_name_6, 1);
float testFraction = ta.getFraction(R.styleable.UITestAttrsView_attr_name_7, 1, 100, 0.0f);
float testFloat = ta.getFloat(R.styleable.UITestAttrsView_attr_name_8, 1.0f);
int testInteger = ta.getInteger(R.styleable.UITestAttrsView_attr_name_9, 1);
/**
* enum 的获取方式
*
@see LinearLayout#setOrientation(int)
int index = a.getInt(com.android.internal.R.styleable.LinearLayout_orientation, -1);
if (index >= 0) {
setOrientation(index);
}
*/
/**
*
* flag 位或运算
* 获取方式
@see View#setScrollBarStyle(int)
case R.styleable.View_scrollbars:
final int scrollbars = a.getInt(attr, SCROLLBARS_NONE);
if (scrollbars != SCROLLBARS_NONE) {
viewFlagValues |= scrollbars;
viewFlagMasks |= SCROLLBARS_MASK;
initializeScrollbars = true;
}
*/
}