List of usage examples for android.content.res TypedArray getDimension
public float getDimension(@StyleableRes int index, float defValue)
From source file:com.me.harris.androidanimations._06_touch.swipelistview.SwipeListView.java
/** * Init ListView// www.j av a 2 s . com * * @param attrs AttributeSet */ private void init(AttributeSet attrs) { int swipeMode = SWIPE_MODE_BOTH; boolean swipeOpenOnLongPress = true; boolean swipeCloseAllItemsWhenMoveList = true; int swipeFrontView = 0; int swipeBackView = 0; long swipeAnimationTime = 0; float swipeOffsetLeft = 0; float swipeOffsetRight = 0; int swipeActionLeft = SWIPE_ACTION_REVEAL; int swipeActionRight = SWIPE_ACTION_REVEAL; if (attrs != null) { TypedArray styled = getContext().obtainStyledAttributes(attrs, R.styleable.SwipeListView); swipeMode = styled.getInt(R.styleable.SwipeListView_swipeMode, SWIPE_MODE_BOTH); swipeActionLeft = styled.getInt(R.styleable.SwipeListView_swipeActionLeft, SWIPE_ACTION_REVEAL); swipeActionRight = styled.getInt(R.styleable.SwipeListView_swipeActionRight, SWIPE_ACTION_REVEAL); swipeOffsetLeft = styled.getDimension(R.styleable.SwipeListView_swipeOffsetLeft, 0); swipeOffsetRight = styled.getDimension(R.styleable.SwipeListView_swipeOffsetRight, 0); swipeOpenOnLongPress = styled.getBoolean(R.styleable.SwipeListView_swipeOpenOnLongPress, true); swipeAnimationTime = styled.getInteger(R.styleable.SwipeListView_swipeAnimationTime, 0); swipeCloseAllItemsWhenMoveList = styled .getBoolean(R.styleable.SwipeListView_swipeCloseAllItemsWhenMoveList, true); swipeFrontView = styled.getResourceId(R.styleable.SwipeListView_swipeFrontView, 0); swipeBackView = styled.getResourceId(R.styleable.SwipeListView_swipeBackView, 0); } if (swipeFrontView == 0 || swipeBackView == 0) { throw new RuntimeException("Missed attribute swipeFrontView or swipeBackView"); } final ViewConfiguration configuration = ViewConfiguration.get(getContext()); touchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); touchListener = new SwipeListViewTouchListener(this, swipeFrontView, swipeBackView); if (swipeAnimationTime > 0) { touchListener.setAnimationTime(swipeAnimationTime); } touchListener.setRightOffset(swipeOffsetRight); touchListener.setLeftOffset(swipeOffsetLeft); touchListener.setSwipeActionLeft(swipeActionLeft); touchListener.setSwipeActionRight(swipeActionRight); touchListener.setSwipeMode(swipeMode); touchListener.setSwipeClosesAllItemsWhenListMoves(swipeCloseAllItemsWhenMoveList); touchListener.setSwipeOpenOnLongPress(swipeOpenOnLongPress); setOnTouchListener(touchListener); setOnScrollListener(touchListener.makeScrollListener()); }
From source file:com.h6ah4i.android.materialshadowninepatch.MaterialShadowContainerView.java
public MaterialShadowContainerView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr); final TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.ms9_MaterialShadowContainerView, defStyleAttr, defStyleRes);//from w ww . j ava 2 s. c o m final float shadowTranslationZ = ta.getDimension( R.styleable.ms9_MaterialShadowContainerView_ms9_shadowTranslationZ, mShadowTranslationZ); final float shadowElevation = ta .getDimension(R.styleable.ms9_MaterialShadowContainerView_ms9_shadowElevation, mShadowElevation); final int spotShadowLevelListResId = ta .getResourceId(R.styleable.ms9_MaterialShadowContainerView_ms9_spotShadowDrawablesList, 0); final int ambientShadowLevelListResId = ta .getResourceId(R.styleable.ms9_MaterialShadowContainerView_ms9_ambientShadowDrawablesList, 0); final boolean forceUseCompatShadow = ta.getBoolean( R.styleable.ms9_MaterialShadowContainerView_ms9_forceUseCompatShadow, mForceUseCompatShadow); final boolean affectsXYPosition = ta.getBoolean( R.styleable.ms9_MaterialShadowContainerView_ms9_affectsDisplayedPosition, mAffectsDisplayedPosition); final boolean useAmbientShadow = ta .getBoolean(R.styleable.ms9_MaterialShadowContainerView_ms9_useAmbientShadow, mUseAmbientShadow); final boolean useSpotShadow = ta.getBoolean(R.styleable.ms9_MaterialShadowContainerView_ms9_useSpotShadow, mUseSpotShadow); ta.recycle(); mSpotShadowResourcesIdList = getResourceIdArray(getResources(), spotShadowLevelListResId); mAmbientShadowResourcesIdList = getResourceIdArray(getResources(), ambientShadowLevelListResId); mMaxSpotShadowLevel = getMaxShadowLevel(mSpotShadowResourcesIdList); mMaxAmbientShadowLevel = getMaxShadowLevel(mAmbientShadowResourcesIdList); mDisplayDensity = getResources().getDisplayMetrics().density; mInvDisplayDensity = 1.0f / mDisplayDensity; mShadowTranslationZ = shadowTranslationZ; mShadowElevation = shadowElevation; mForceUseCompatShadow = forceUseCompatShadow; mAffectsDisplayedPosition = affectsXYPosition; mUseAmbientShadow = useAmbientShadow; mUseSpotShadow = useSpotShadow; updateShadowLevel(true); }
From source file:com.evilduck.piano.views.instrument.PianoView.java
public PianoView(Context context, AttributeSet attrs) { super(context, attrs); init();/*from w ww .jav a 2 s . c om*/ leftEdgeEffect = new EdgeEffectCompat(getContext()); rightEdgeEffect = new EdgeEffectCompat(getContext()); setVerticalScrollBarEnabled(false); setHorizontalScrollBarEnabled(true); TypedArray a = context.obtainStyledAttributes(R.styleable.View); initializeScrollbars(a); a.recycle(); TypedArray pianoAttrs = context.obtainStyledAttributes(attrs, R.styleable.PianoView); boolean asBitmaps; int circleColor; float circleRadius; float circleTextSize; try { asBitmaps = pianoAttrs.getBoolean(R.styleable.PianoView_overlay_bitmaps, true); circleColor = pianoAttrs.getColor(R.styleable.PianoView_overlay_color, Color.GREEN); circleRadius = pianoAttrs.getDimension(R.styleable.PianoView_overlay_circle_radius, TypedValue .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24, context.getResources().getDisplayMetrics())); circleTextSize = pianoAttrs.getDimension(R.styleable.PianoView_overlay_circle_text_size, TypedValue .applyDimension(TypedValue.COMPLEX_UNIT_SP, 12, context.getResources().getDisplayMetrics())); } finally { pianoAttrs.recycle(); } keyboard = new Keyboard(getContext(), asBitmaps, circleColor, circleRadius, circleTextSize); }
From source file:com.jakewharton.android.viewpagerindicator.TitlePageIndicator.java
public TitlePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); //Load defaults from resources final Resources res = getResources(); final int defaultFooterColor = res.getColor(R.color.default_title_indicator_footer_color); final float defaultFooterLineHeight = res.getDimension(R.dimen.default_title_indicator_footer_line_height); final int defaultFooterIndicatorStyle = res .getInteger(R.integer.default_title_indicator_footer_indicator_style); final float defaultFooterIndicatorHeight = res .getDimension(R.dimen.default_title_indicator_footer_indicator_height); final float defaultFooterIndicatorUnderlinePadding = res .getDimension(R.dimen.default_title_indicator_footer_indicator_underline_padding); final float defaultFooterPadding = res.getDimension(R.dimen.default_title_indicator_footer_padding); final int defaultSelectedColor = res.getColor(R.color.default_title_indicator_selected_color); final boolean defaultSelectedBold = res.getBoolean(R.bool.default_title_indicator_selected_bold); final int defaultTextColor = res.getColor(R.color.default_title_indicator_text_color); final float defaultTextSize = res.getDimension(R.dimen.default_title_indicator_text_size); final float defaultTitlePadding = res.getDimension(R.dimen.default_title_indicator_title_padding); final float defaultClipPadding = res.getDimension(R.dimen.default_title_indicator_clip_padding); //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TitlePageIndicator, defStyle, R.style.Widget_TitlePageIndicator); //Retrieve the colors to be used for this view and apply them. mFooterLineHeight = a.getDimension(R.styleable.TitlePageIndicator_footerLineHeight, defaultFooterLineHeight);/*from ww w .j ava 2 s .c o m*/ mFooterIndicatorStyle = IndicatorStyle.fromValue( a.getInteger(R.styleable.TitlePageIndicator_footerIndicatorStyle, defaultFooterIndicatorStyle)); mFooterIndicatorHeight = a.getDimension(R.styleable.TitlePageIndicator_footerIndicatorHeight, defaultFooterIndicatorHeight); mFooterIndicatorUnderlinePadding = a.getDimension( R.styleable.TitlePageIndicator_footerIndicatorUnderlinePadding, defaultFooterIndicatorUnderlinePadding); mFooterPadding = a.getDimension(R.styleable.TitlePageIndicator_footerPadding, defaultFooterPadding); mTitlePadding = a.getDimension(R.styleable.TitlePageIndicator_titlePadding, defaultTitlePadding); mClipPadding = a.getDimension(R.styleable.TitlePageIndicator_clipPadding, defaultClipPadding); mColorSelected = a.getColor(R.styleable.TitlePageIndicator_selectedColor, defaultSelectedColor); mColorText = a.getColor(R.styleable.TitlePageIndicator_textColor, defaultTextColor); mBoldText = a.getBoolean(R.styleable.TitlePageIndicator_selectedBold, defaultSelectedBold); final float textSize = a.getDimension(R.styleable.TitlePageIndicator_textSize, defaultTextSize); final int footerColor = a.getColor(R.styleable.TitlePageIndicator_footerColor, defaultFooterColor); mPaintText = new Paint(); mPaintText.setTextSize(textSize); mPaintText.setAntiAlias(true); mPaintFooterLine = new Paint(); mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE); mPaintFooterLine.setStrokeWidth(mFooterLineHeight); mPaintFooterLine.setColor(footerColor); mPaintFooterIndicator = new Paint(); mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE); mPaintFooterIndicator.setColor(footerColor); a.recycle(); }
From source file:com.cicada.startup.common.ui.view.indicator.ViewPagerIndicator.java
public ViewPagerIndicator(Context context, AttributeSet attrs) { super(context, attrs); setHorizontalScrollBarEnabled(false); // ?????? scroller = new Scroller(context); if (attrs != null) { TypedArray attrsTypedArray = context.obtainStyledAttributes(attrs, R.styleable.ViewPagerIndicator); if (attrsTypedArray != null) { allowWidthFull = attrsTypedArray.getBoolean(R.styleable.ViewPagerIndicator_allowWidthFull, false); slidingBlockDrawable = attrsTypedArray.getDrawable(R.styleable.ViewPagerIndicator_slidingBlock); slidingBlockHeight = (int) attrsTypedArray .getDimension(R.styleable.ViewPagerIndicator_slidingBlockHeight, 8); disableViewPager = attrsTypedArray.getBoolean(R.styleable.ViewPagerIndicator_disableViewPager, false);//from ww w . j av a2 s . com attrsTypedArray.recycle(); } } }
From source file:com.alimuzaffar.lib.widgets.PinEntryEditText.java
private void init(Context context, AttributeSet attrs) { float multi = context.getResources().getDisplayMetrics().density; mLineStroke = multi * mLineStroke;/*from w w w .j a v a2 s. c om*/ mLineStrokeSelected = multi * mLineStrokeSelected; mSpace = multi * mSpace; //convert to pixels for our density mTextBottomPadding = multi * mTextBottomPadding; //convert to pixels for our density TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.PinEntryEditText, 0, 0); try { TypedValue outValue = new TypedValue(); ta.getValue(R.styleable.PinEntryEditText_pinAnimationType, outValue); mAnimatedType = outValue.data; mMask = ta.getString(R.styleable.PinEntryEditText_pinCharacterMask); mLineStroke = ta.getDimension(R.styleable.PinEntryEditText_pinLineStroke, mLineStroke); mLineStrokeSelected = ta.getDimension(R.styleable.PinEntryEditText_pinLineStrokeSelected, mLineStrokeSelected); mSpace = ta.getDimension(R.styleable.PinEntryEditText_pinCharacterSpacing, mSpace); mTextBottomPadding = ta.getDimension(R.styleable.PinEntryEditText_pinTextBottomPadding, mTextBottomPadding); mIsDigitSquare = ta.getBoolean(R.styleable.PinEntryEditText_pinBackgroundIsSquare, mIsDigitSquare); mPinBackground = ta.getDrawable(R.styleable.PinEntryEditText_pinBackgroundDrawable); ColorStateList colors = ta.getColorStateList(R.styleable.PinEntryEditText_pinLineColors); if (colors != null) { mColorStates = colors; } } finally { ta.recycle(); } mCharPaint = new Paint(getPaint()); mLastCharPaint = new Paint(getPaint()); mLinesPaint = new Paint(getPaint()); mLinesPaint.setStrokeWidth(mLineStroke); TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(R.attr.colorControlActivated, outValue, true); int colorSelected = outValue.data; mColors[0] = colorSelected; int colorFocused = isInEditMode() ? Color.GRAY : ContextCompat.getColor(context, R.color.pin_normal); mColors[1] = colorFocused; int colorUnfocused = isInEditMode() ? Color.GRAY : ContextCompat.getColor(context, R.color.pin_normal); mColors[2] = colorUnfocused; setBackgroundResource(0); mMaxLength = attrs.getAttributeIntValue(XML_NAMESPACE_ANDROID, "maxLength", 4); mNumChars = mMaxLength; //Disable copy paste super.setCustomSelectionActionModeCallback(new ActionMode.Callback() { public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } public void onDestroyActionMode(ActionMode mode) { } public boolean onCreateActionMode(ActionMode mode, Menu menu) { return false; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { return false; } }); // When tapped, move cursor to end of text. super.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setSelection(getText().length()); if (mClickListener != null) { mClickListener.onClick(v); } } }); super.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { setSelection(getText().length()); return true; } }); //If input type is password and no mask is set, use a default mask if ((getInputType() & InputType.TYPE_TEXT_VARIATION_PASSWORD) == InputType.TYPE_TEXT_VARIATION_PASSWORD && TextUtils.isEmpty(mMask)) { mMask = "\u25CF"; } else if ((getInputType() & InputType.TYPE_NUMBER_VARIATION_PASSWORD) == InputType.TYPE_NUMBER_VARIATION_PASSWORD && TextUtils.isEmpty(mMask)) { mMask = "\u25CF"; } if (!TextUtils.isEmpty(mMask)) { mMaskChars = getMaskChars(); } //Height of the characters, used if there is a background drawable getPaint().getTextBounds("|", 0, 1, mTextHeight); }
From source file:com.android.core.view.indicator.UnderlinePageIndicator.java
public UnderlinePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;/*from w w w . ja v a 2 s.c o m*/ final Resources res = getResources(); //Load defaults from resources final boolean defaultFades = res.getBoolean(R.bool.default_underline_indicator_fades); final int defaultFadeDelay = res.getInteger(R.integer.default_underline_indicator_fade_delay); final int defaultFadeLength = res.getInteger(R.integer.default_underline_indicator_fade_length); final int defaultSelectedColor = res.getColor(R.color.default_underline_indicator_selected_color); final float defaultLineWidth = 0f; //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.UnderlinePageIndicator, defStyle, 0); setFades(a.getBoolean(R.styleable.UnderlinePageIndicator_fades, defaultFades)); setSelectedColor(a.getColor(R.styleable.UnderlinePageIndicator_selectedColor, defaultSelectedColor)); setFadeDelay(a.getInteger(R.styleable.UnderlinePageIndicator_fadeDelay, defaultFadeDelay)); setFadeLength(a.getInteger(R.styleable.UnderlinePageIndicator_fadeLength, defaultFadeLength)); setLineWidth(a.getDimension(R.styleable.UnderlinePageIndicator_line_width, defaultLineWidth)); Drawable background = a.getDrawable(R.styleable.UnderlinePageIndicator_android_background); if (background != null) { setBackgroundDrawable(background); } a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:com.androtex.viewpagerindicator.TitlePageIndicator.java
public TitlePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); //Load defaults from resources final Resources res = getResources(); final int defaultFooterColor = res.getColor(R.color.default_title_indicator_footer_color); final float defaultFooterLineHeight = res.getDimension(R.dimen.default_title_indicator_footer_line_height); final int defaultFooterIndicatorStyle = res .getInteger(R.integer.default_title_indicator_footer_indicator_style); final float defaultFooterIndicatorHeight = res .getDimension(R.dimen.default_title_indicator_footer_indicator_height); final float defaultFooterIndicatorUnderlinePadding = res .getDimension(R.dimen.default_title_indicator_footer_indicator_underline_padding); final float defaultFooterPadding = res.getDimension(R.dimen.default_title_indicator_footer_padding); @SuppressWarnings("unused") final int defaultSelectedColor = res.getColor(R.color.default_title_indicator_selected_color); final boolean defaultSelectedBold = res.getBoolean(R.bool.default_title_indicator_selected_bold); final int defaultTextColor = res.getColor(R.color.default_title_indicator_text_color); final float defaultTextSize = res.getDimension(R.dimen.default_title_indicator_text_size); final float defaultTitlePadding = res.getDimension(R.dimen.default_title_indicator_title_padding); final float defaultClipPadding = res.getDimension(R.dimen.default_title_indicator_clip_padding); final float defaultTopPadding = res.getDimension(R.dimen.default_title_indicator_top_padding); //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TitlePageIndicator, defStyle, R.style.Widget_TitlePageIndicator); //Retrieve the colors to be used for this view and apply them. mFooterLineHeight = a.getDimension(R.styleable.TitlePageIndicator_footerLineHeight, defaultFooterLineHeight);/*from ww w .jav a 2 s . co m*/ mFooterIndicatorStyle = IndicatorStyle.fromValue( a.getInteger(R.styleable.TitlePageIndicator_footerIndicatorStyle, defaultFooterIndicatorStyle)); mFooterIndicatorHeight = a.getDimension(R.styleable.TitlePageIndicator_footerIndicatorHeight, defaultFooterIndicatorHeight); mFooterIndicatorUnderlinePadding = a.getDimension( R.styleable.TitlePageIndicator_footerIndicatorUnderlinePadding, defaultFooterIndicatorUnderlinePadding); mFooterPadding = a.getDimension(R.styleable.TitlePageIndicator_footerPadding, defaultFooterPadding); mTopPadding = a.getDimension(R.styleable.TitlePageIndicator_topPadding, defaultTopPadding); mTitlePadding = a.getDimension(R.styleable.TitlePageIndicator_titlePadding, defaultTitlePadding); mClipPadding = a.getDimension(R.styleable.TitlePageIndicator_clipPadding, defaultClipPadding); mColorSelected = 0; //a.getColor(R.styleable.TitlePageIndicator_selectedColor, defaultSelectedColor); mColorText = a.getColor(R.styleable.TitlePageIndicator_textColor, defaultTextColor); mBoldText = a.getBoolean(R.styleable.TitlePageIndicator_selectedBold, defaultSelectedBold); final float textSize = a.getDimension(R.styleable.TitlePageIndicator_textSize, defaultTextSize); final int footerColor = a.getColor(R.styleable.TitlePageIndicator_footerColor, defaultFooterColor); mPaintText = new Paint(); mPaintText.setTextSize(textSize); mPaintText.setAntiAlias(true); mPaintFooterLine = new Paint(); mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE); mPaintFooterLine.setStrokeWidth(mFooterLineHeight); mPaintFooterLine.setColor(footerColor); mPaintFooterIndicator = new Paint(); mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE); mPaintFooterIndicator.setColor(footerColor); a.recycle(); }
From source file:com.lbk.app.weiliao.ui.views.TitlePageIndicator.java
public TitlePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); //Load defaults from resources final Resources res = getResources(); final int defaultFooterColor = res.getColor(R.color.default_title_indicator_footer_color); final float defaultFooterLineHeight = res.getDimension(R.dimen.default_title_indicator_footer_line_height); final int defaultFooterIndicatorStyle = res .getInteger(R.integer.default_title_indicator_footer_indicator_style); final float defaultFooterIndicatorHeight = res .getDimension(R.dimen.default_title_indicator_footer_indicator_height); final float defaultFooterIndicatorUnderlinePadding = res .getDimension(R.dimen.default_title_indicator_footer_indicator_underline_padding); final float defaultFooterPadding = res.getDimension(R.dimen.default_title_indicator_footer_padding); final int defaultSelectedColor = res.getColor(R.color.default_title_indicator_selected_color); final boolean defaultSelectedBold = res.getBoolean(R.bool.default_title_indicator_selected_bold); final int defaultTextColor = res.getColor(R.color.default_title_indicator_text_color); final float defaultTextSize = res.getDimension(R.dimen.default_title_indicator_text_size); final float defaultTitlePadding = res.getDimension(R.dimen.default_title_indicator_title_padding); final float defaultClipPadding = res.getDimension(R.dimen.default_title_indicator_clip_padding); final float defaultTopPadding = res.getDimension(R.dimen.default_title_indicator_top_padding); //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TitlePageIndicator, defStyle, R.style.Widget_TitlePageIndicator); //Retrieve the colors to be used for this view and apply them. mFooterLineHeight = a.getDimension(R.styleable.TitlePageIndicator_footerLineHeight, defaultFooterLineHeight);/*from www . j a v a 2 s . co m*/ mFooterIndicatorStyle = IndicatorStyle.fromValue( a.getInteger(R.styleable.TitlePageIndicator_footerIndicatorStyle, defaultFooterIndicatorStyle)); mFooterIndicatorHeight = a.getDimension(R.styleable.TitlePageIndicator_footerIndicatorHeight, defaultFooterIndicatorHeight); mFooterIndicatorUnderlinePadding = a.getDimension( R.styleable.TitlePageIndicator_footerIndicatorUnderlinePadding, defaultFooterIndicatorUnderlinePadding); mFooterPadding = a.getDimension(R.styleable.TitlePageIndicator_footerPadding, defaultFooterPadding); mTopPadding = a.getDimension(R.styleable.TitlePageIndicator_topPadding, defaultTopPadding); mTitlePadding = a.getDimension(R.styleable.TitlePageIndicator_titlePadding, defaultTitlePadding); mClipPadding = a.getDimension(R.styleable.TitlePageIndicator_clipPadding, defaultClipPadding); mColorSelected = a.getColor(R.styleable.TitlePageIndicator_selectedColor, defaultSelectedColor); mColorText = a.getColor(R.styleable.TitlePageIndicator_textColor, defaultTextColor); mBoldText = a.getBoolean(R.styleable.TitlePageIndicator_selectedBold, defaultSelectedBold); final float textSize = a.getDimension(R.styleable.TitlePageIndicator_textSize, defaultTextSize); final int footerColor = a.getColor(R.styleable.TitlePageIndicator_footerColor, defaultFooterColor); mPaintText = new Paint(); mPaintText.setTextSize(textSize); mPaintText.setAntiAlias(true); mPaintFooterLine = new Paint(); mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE); mPaintFooterLine.setStrokeWidth(mFooterLineHeight); mPaintFooterLine.setColor(footerColor); mPaintFooterIndicator = new Paint(); mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE); mPaintFooterIndicator.setColor(footerColor); a.recycle(); }
From source file:com.fortysevendeg.android.swipelistview.SwipeListView.java
/** * Init ListView/*from w w w. j a va 2s.c o m*/ * * @param attrs AttributeSet */ private void init(AttributeSet attrs) { int swipeMode = SWIPE_MODE_BOTH; boolean swipeOpenOnLongPress = true; boolean swipeCloseAllItemsWhenMoveList = true; long swipeAnimationTime = 0; float swipeOffsetLeft = 0; float swipeOffsetRight = 0; int swipeActionLeft = SWIPE_ACTION_REVEAL; int swipeActionRight = SWIPE_ACTION_REVEAL; if (attrs != null) { TypedArray styled = getContext().obtainStyledAttributes(attrs, R.styleable.SwipeListView); swipeMode = styled.getInt(R.styleable.SwipeListView_swipeMode, SWIPE_MODE_BOTH); swipeActionLeft = styled.getInt(R.styleable.SwipeListView_swipeActionLeft, SWIPE_ACTION_REVEAL); swipeActionRight = styled.getInt(R.styleable.SwipeListView_swipeActionRight, SWIPE_ACTION_REVEAL); swipeOffsetLeft = styled.getDimension(R.styleable.SwipeListView_swipeOffsetLeft, 0); swipeOffsetRight = styled.getDimension(R.styleable.SwipeListView_swipeOffsetRight, 0); swipeOpenOnLongPress = styled.getBoolean(R.styleable.SwipeListView_swipeOpenOnLongPress, true); swipeAnimationTime = styled.getInteger(R.styleable.SwipeListView_swipeAnimationTime, 0); swipeCloseAllItemsWhenMoveList = styled .getBoolean(R.styleable.SwipeListView_swipeCloseAllItemsWhenMoveList, true); swipeFrontView = styled.getResourceId(R.styleable.SwipeListView_swipeFrontView, 0); swipeBackView = styled.getResourceId(R.styleable.SwipeListView_swipeBackView, 0); } if (swipeFrontView == 0 || swipeBackView == 0) { throw new RuntimeException("Missed attribute swipeFrontView or swipeBackView"); } final ViewConfiguration configuration = ViewConfiguration.get(getContext()); touchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); touchListener = new SwipeListViewTouchListener(this, swipeFrontView, swipeBackView); if (swipeAnimationTime > 0) { touchListener.setAnimationTime(swipeAnimationTime); } touchListener.setRightOffset(swipeOffsetRight); touchListener.setLeftOffset(swipeOffsetLeft); touchListener.setSwipeActionLeft(swipeActionLeft); touchListener.setSwipeActionRight(swipeActionRight); touchListener.setSwipeMode(swipeMode); touchListener.setSwipeClosesAllItemsWhenListMoves(swipeCloseAllItemsWhenMoveList); touchListener.setSwipeOpenOnLongPress(swipeOpenOnLongPress); setOnTouchListener(touchListener); setOnScrollListener(touchListener.makeScrollListener()); }