List of usage examples for android.content.res TypedArray getInt
public int getInt(@StyleableRes int index, int defValue)
From source file:com.jp.fristandroidapp.widget.adview.AdViewFlow.java
public AdViewFlow(Context context, AttributeSet attrs) { super(context, attrs); TypedArray styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.ViewFlow); mSideBuffer = styledAttrs.getInt(R.styleable.ViewFlow_sidebuffer, 0); init();/*from ww w. j a v a 2 s .c o m*/ }
From source file:cn.fantasee.swipwmenulistview.swipelistview.SwipeListView.java
/** * Init ListView// w w w . j a v a 2 s . c om * * @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 swipeDrawableChecked = 0; int swipeDrawableUnchecked = 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); swipeDrawableChecked = styled.getResourceId(R.styleable.SwipeListView_swipeDrawableChecked, 0); swipeDrawableUnchecked = styled.getResourceId(R.styleable.SwipeListView_swipeDrawableUnchecked, 0); swipeFrontView = styled.getResourceId(R.styleable.SwipeListView_swipeFrontView, 0); swipeBackView = styled.getResourceId(R.styleable.SwipeListView_swipeBackView, 0); styled.recycle(); } if (swipeFrontView == 0 || swipeBackView == 0) { swipeFrontView = getContext().getResources().getIdentifier(SWIPE_DEFAULT_FRONT_VIEW, "id", getContext().getPackageName()); swipeBackView = getContext().getResources().getIdentifier(SWIPE_DEFAULT_BACK_VIEW, "id", getContext().getPackageName()); if (swipeFrontView == 0 || swipeBackView == 0) { throw new RuntimeException(String.format( "You forgot the attributes swipeFrontView or swipeBackView. You can add this attributes or use '%s' and '%s' identifiers", SWIPE_DEFAULT_FRONT_VIEW, SWIPE_DEFAULT_BACK_VIEW)); } } 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); touchListener.setSwipeDrawableChecked(swipeDrawableChecked); touchListener.setSwipeDrawableUnchecked(swipeDrawableUnchecked); setOnTouchListener(touchListener); setOnScrollListener(touchListener.makeScrollListener()); }
From source file:com.example.zhangyipeng.swipelibrary.SwipeListView.java
/** * Init ListView/*from w w w . j a v a 2s . c om*/ * * @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 swipeDrawableChecked = 0; int swipeDrawableUnchecked = 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); swipeDrawableChecked = styled.getResourceId(R.styleable.SwipeListView_swipeDrawableChecked, 0); swipeDrawableUnchecked = styled.getResourceId(R.styleable.SwipeListView_swipeDrawableUnchecked, 0); swipeFrontView = styled.getResourceId(R.styleable.SwipeListView_swipeFrontView, 0); swipeBackView = styled.getResourceId(R.styleable.SwipeListView_swipeBackView, 0); styled.recycle(); } if (swipeFrontView == 0 || swipeBackView == 0) { swipeFrontView = getContext().getResources().getIdentifier(SWIPE_DEFAULT_FRONT_VIEW, "id", getContext().getPackageName()); swipeBackView = getContext().getResources().getIdentifier(SWIPE_DEFAULT_BACK_VIEW, "id", getContext().getPackageName()); if (swipeFrontView == 0 || swipeBackView == 0) { throw new RuntimeException(String.format( "You forgot the attributes swipeFrontView or swipeBackView. You can add this attributes or use '%s' and '%s' identifiers", SWIPE_DEFAULT_FRONT_VIEW, SWIPE_DEFAULT_BACK_VIEW)); } } 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); touchListener.setSwipeDrawableChecked(swipeDrawableChecked); touchListener.setSwipeDrawableUnchecked(swipeDrawableUnchecked); setOnTouchListener(touchListener); setOnScrollListener(touchListener.makeScrollListener()); }
From source file:com.android.inputmethod.latin.suggestions.SuggestionStripLayoutHelper.java
public SuggestionStripLayoutHelper(final Context context, final AttributeSet attrs, final int defStyle, final ArrayList<TextView> wordViews, final ArrayList<View> dividerViews, final ArrayList<TextView> debugInfoViews) { mWordViews = wordViews;/*from w w w . ja v a 2s . c o m*/ mDividerViews = dividerViews; mDebugInfoViews = debugInfoViews; final TextView wordView = wordViews.get(0); final View dividerView = dividerViews.get(0); mPadding = wordView.getCompoundPaddingLeft() + wordView.getCompoundPaddingRight(); dividerView.measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); mDividerWidth = dividerView.getMeasuredWidth(); final Resources res = wordView.getResources(); mSuggestionsStripHeight = res.getDimensionPixelSize(R.dimen.config_suggestions_strip_height); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SuggestionStripView, defStyle, R.style.SuggestionStripView); mSuggestionStripOptions = a.getInt(R.styleable.SuggestionStripView_suggestionStripOptions, 0); mAlphaObsoleted = ResourceUtils.getFraction(a, R.styleable.SuggestionStripView_alphaObsoleted, 1.0f); mColorValidTypedWord = a.getColor(R.styleable.SuggestionStripView_colorValidTypedWord, 0); mColorTypedWord = a.getColor(R.styleable.SuggestionStripView_colorTypedWord, 0); mColorAutoCorrect = a.getColor(R.styleable.SuggestionStripView_colorAutoCorrect, 0); mColorSuggested = a.getColor(R.styleable.SuggestionStripView_colorSuggested, 0); mSuggestionsCountInStrip = a.getInt(R.styleable.SuggestionStripView_suggestionsCountInStrip, DEFAULT_SUGGESTIONS_COUNT_IN_STRIP); mCenterSuggestionWeight = ResourceUtils.getFraction(a, R.styleable.SuggestionStripView_centerSuggestionPercentile, DEFAULT_CENTER_SUGGESTION_PERCENTILE); mMaxMoreSuggestionsRow = a.getInt(R.styleable.SuggestionStripView_maxMoreSuggestionsRow, DEFAULT_MAX_MORE_SUGGESTIONS_ROW); mMinMoreSuggestionsWidth = ResourceUtils.getFraction(a, R.styleable.SuggestionStripView_minMoreSuggestionsWidth, 1.0f); a.recycle(); mMoreSuggestionsHint = getMoreSuggestionsHint(res, res.getDimension(R.dimen.config_more_suggestions_hint_text_size), mColorAutoCorrect); mCenterPositionInStrip = mSuggestionsCountInStrip / 2; // Assuming there are at least three suggestions. Also, note that the suggestions are // laid out according to script direction, so this is left of the center for LTR scripts // and right of the center for RTL scripts. mTypedWordPositionWhenAutocorrect = mCenterPositionInStrip - 1; mMoreSuggestionsBottomGap = res.getDimensionPixelOffset(R.dimen.config_more_suggestions_bottom_gap); mMoreSuggestionsRowHeight = res.getDimensionPixelSize(R.dimen.config_more_suggestions_row_height); }
From source file:com.itsronald.widget.ViewPagerIndicator.java
private void init(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.ViewPagerIndicator, defStyleAttr, defStyleRes);/*from w w w . ja va2 s .c o m*/ gravity = attributes.getInt(R.styleable.ViewPagerIndicator_android_gravity, gravity); final float scale = getResources().getDisplayMetrics().density; final int defaultDotPadding = (int) (DEFAULT_DOT_PADDING_DIP * scale + 0.5); dotPadding = attributes.getDimensionPixelSize(R.styleable.ViewPagerIndicator_dotPadding, defaultDotPadding); final int defaultDotRadius = (int) (IndicatorDotView.DEFAULT_DOT_RADIUS_DIP * scale + 0.5); dotRadius = attributes.getDimensionPixelSize(R.styleable.ViewPagerIndicator_dotRadius, defaultDotRadius); unselectedDotColor = attributes.getColor(R.styleable.ViewPagerIndicator_unselectedDotColor, IndicatorDotView.DEFAULT_UNSELECTED_DOT_COLOR); selectedDotColor = attributes.getColor(R.styleable.ViewPagerIndicator_selectedDotColor, IndicatorDotView.DEFAULT_SELECTED_DOT_COLOR); attributes.recycle(); selectedDot = new IndicatorDotView(context); selectedDot.setColor(selectedDotColor); selectedDot.setRadius(dotRadius); }
From source file:com.andremion.music.MusicCoverView.java
public MusicCoverView(Context context, AttributeSet attrs, final int defStyleAttr) { super(context, attrs, defStyleAttr); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MusicCoverView); @Shape//from www . j av a 2 s . co m int shape = a.getInt(R.styleable.MusicCoverView_shape, SHAPE_SQUARE); @ColorInt int trackColor = a.getColor(R.styleable.MusicCoverView_trackColor, TRACK_COLOR); a.recycle(); // TODO: Canvas.clipPath works wrong when running with hardware acceleration on Android N if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) { setLayerType(View.LAYER_TYPE_HARDWARE, null); } final float density = getResources().getDisplayMetrics().density; mTrackSize = TRACK_SIZE * density; mTrackPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mTrackPaint.setStyle(Paint.Style.STROKE); mTrackPaint.setStrokeWidth(TRACK_WIDTH * density); mDiscPaintCenterDecor = new Paint(Paint.ANTI_ALIAS_FLAG); mDiscPaintCenterDecor.setStyle(Paint.Style.FILL); mDiscPaintCenter = new Paint(Paint.ANTI_ALIAS_FLAG); mDiscPaintCenter.setStyle(Paint.Style.FILL); setShape(shape); setTrackColor(trackColor); if (getDrawable() != null && ((BitmapDrawable) getDrawable()).getBitmap() != null) { setCenterColor(DISC_CENTER_COLOR, Palette.generate(((BitmapDrawable) getDrawable()).getBitmap(), 32) .getLightVibrantColor(DISC_CENTER_DECOR_COLOR)); } else { setCenterColor(DISC_CENTER_COLOR, DISC_CENTER_DECOR_COLOR); } setScaleType(); mStartRotateAnimator = ObjectAnimator.ofFloat(this, View.ROTATION, 0, FULL_ANGLE); mStartRotateAnimator.setInterpolator(new LinearInterpolator()); if (SHAPE_SQUARE == mShape) { mStartRotateAnimator.setDuration(DURATION_SQUARE); } else { mStartRotateAnimator.setDuration(DURATION); mStartRotateAnimator.setRepeatCount(Animation.INFINITE); } mStartRotateAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { float current = getRotation(); float target = current > HALF_ANGLE ? FULL_ANGLE : 0; // Choose the shortest distance to 0 rotation float diff = target > 0 ? FULL_ANGLE - current : current; mEndRotateAnimator.setFloatValues(current, target); if (SHAPE_SQUARE == mShape) { mEndRotateAnimator.setDuration((int) (DURATION_SQUARE_PER_DEGREES * diff)); } else { mEndRotateAnimator.setDuration((int) (DURATION_PER_DEGREES * diff)); } mEndRotateAnimator.start(); } }); mEndRotateAnimator = ObjectAnimator.ofFloat(MusicCoverView.this, View.ROTATION, 0); mEndRotateAnimator.setInterpolator(new LinearInterpolator()); mEndRotateAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { setRotation(0); // isRunning method return true if it's called form here. // So we need call from post method to get the right returning. post(new Runnable() { @Override public void run() { if (mCallbacks != null) { mCallbacks.onRotateEnd(MusicCoverView.this); } } }); } }); mRectToCircleTransition = new MorphTransition(SHAPE_RECTANGLE); mRectToCircleTransition.addTarget(this); mRectToCircleTransition.addListener(new TransitionAdapter() { @Override public void onTransitionStart(Transition transition) { mIsMorphing = true; } @Override public void onTransitionEnd(Transition transition) { mIsMorphing = false; mShape = SHAPE_CIRCLE; if (mCallbacks != null) { mCallbacks.onMorphEnd(MusicCoverView.this); } } }); mCircleToRectTransition = new MorphTransition(SHAPE_CIRCLE); mCircleToRectTransition.addTarget(this); mCircleToRectTransition.addListener(new TransitionAdapter() { @Override public void onTransitionStart(Transition transition) { mIsMorphing = true; } @Override public void onTransitionEnd(Transition transition) { mIsMorphing = false; mShape = SHAPE_RECTANGLE; if (mCallbacks != null) { mCallbacks.onMorphEnd(MusicCoverView.this); } } }); mSquareToSquareTransition = new MorphTransition(SHAPE_SQUARE); mSquareToSquareTransition.addTarget(this); mSquareToSquareTransition.addListener(new TransitionAdapter() { @Override public void onTransitionStart(Transition transition) { mIsMorphing = true; } @Override public void onTransitionEnd(Transition transition) { mIsMorphing = false; mShape = SHAPE_SQUARE; if (mCallbacks != null) { mCallbacks.onMorphEnd(MusicCoverView.this); } } }); }
From source file:com.example.zhangyipeng.swipelibrary.SwipeListView2.java
/** * Init ListView//from www . ja v a2 s .c om * * @param attrs AttributeSet */ private void init(AttributeSet attrs) { int swipeMode = SWIPE_MODE_BOTH; boolean swipeOpenOnLongPress = true; boolean swipeCloseAllItemsWhenMoveList = true; //?? boolean onlyOneOpenedWhenSwipe = false; long swipeAnimationTime = 0; float swipeOffsetLeft = 0; float swipeOffsetRight = 0; int swipeDrawableChecked = 0; int swipeDrawableUnchecked = 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); onlyOneOpenedWhenSwipe = styled.getBoolean(R.styleable.SwipeListView_onlyOneOpenedWhenSwipe, false); swipeOpenOnLongPress = styled.getBoolean(R.styleable.SwipeListView_swipeOpenOnLongPress, true); swipeAnimationTime = styled.getInteger(R.styleable.SwipeListView_swipeAnimationTime, 0); swipeCloseAllItemsWhenMoveList = styled .getBoolean(R.styleable.SwipeListView_swipeCloseAllItemsWhenMoveList, true); swipeDrawableChecked = styled.getResourceId(R.styleable.SwipeListView_swipeDrawableChecked, 0); swipeDrawableUnchecked = styled.getResourceId(R.styleable.SwipeListView_swipeDrawableUnchecked, 0); swipeFrontView = styled.getResourceId(R.styleable.SwipeListView_swipeFrontView, 0); swipeBackView = styled.getResourceId(R.styleable.SwipeListView_swipeBackView, 0); styled.recycle(); } if (swipeFrontView == 0 || swipeBackView == 0) { swipeFrontView = getContext().getResources().getIdentifier(SWIPE_DEFAULT_FRONT_VIEW, "id", getContext().getPackageName()); swipeBackView = getContext().getResources().getIdentifier(SWIPE_DEFAULT_BACK_VIEW, "id", getContext().getPackageName()); if (swipeFrontView == 0 || swipeBackView == 0) { throw new RuntimeException(String.format( "You forgot the attributes swipeFrontView or swipeBackView. You can add this attributes or use '%s' and '%s' identifiers", SWIPE_DEFAULT_FRONT_VIEW, SWIPE_DEFAULT_BACK_VIEW)); } } final ViewConfiguration configuration = ViewConfiguration.get(getContext()); touchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);//? touchListener = new SwipeListViewTouchListener2(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.setOnlyOneOpenedWhenSwipe(onlyOneOpenedWhenSwipe); touchListener.setSwipeClosesAllItemsWhenListMoves(swipeCloseAllItemsWhenMoveList); touchListener.setSwipeOpenOnLongPress(swipeOpenOnLongPress); touchListener.setSwipeDrawableChecked(swipeDrawableChecked); touchListener.setSwipeDrawableUnchecked(swipeDrawableUnchecked); setOnTouchListener(touchListener); setOnScrollListener(touchListener.makeScrollListener()); }
From source file:be.virtualsushi.gaz.view.ActivityChooserView.java
/** * Create a new instance.//from ww w . j a v a 2 s . c o m * * @param context * The application environment. * @param attrs * A collection of attributes. * @param defStyle * The default style to apply to this view. */ public ActivityChooserView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); TypedArray attributesArray = context.obtainStyledAttributes(attrs, R.styleable.ActivityChooserView, defStyle, 0); mInitialActivityCount = attributesArray.getInt(R.styleable.ActivityChooserView_initialActivityCount, ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_DEFAULT); Drawable expandActivityOverflowButtonDrawable = attributesArray .getDrawable(R.styleable.ActivityChooserView_expandActivityOverflowButtonDrawable); attributesArray.recycle(); LayoutInflater inflater = LayoutInflater.from(getContext()); inflater.inflate(R.layout.abc_activity_chooser_view, this, true); mCallbacks = new Callbacks(); mActivityChooserContent = (LinearLayout) findViewById(R.id.activity_chooser_view_content); mActivityChooserContent.setBackgroundDrawable(null); findViewById(R.id.default_activity_button).setVisibility(GONE); mExpandActivityOverflowButton = (FrameLayout) findViewById(R.id.expand_activities_button); mExpandActivityOverflowButton.setOnClickListener(mCallbacks); mExpandActivityOverflowButtonImage = (ImageView) mExpandActivityOverflowButton.findViewById(R.id.image); mExpandActivityOverflowButtonImage.setImageDrawable(expandActivityOverflowButtonDrawable); mAdapter = new ActivityChooserViewAdapter(); mAdapter.registerDataSetObserver(new DataSetObserver() { @Override public void onChanged() { super.onChanged(); updateAppearance(); } }); Resources resources = context.getResources(); mListPopupMaxWidth = Math.max(resources.getDisplayMetrics().widthPixels / 2, resources.getDimensionPixelSize(R.dimen.abc_config_prefDialogWidth)); }
From source file:com.mobiletin.inputmethod.indic.suggestions.SuggestionStripLayoutHelper.java
public SuggestionStripLayoutHelper(final Context context, final AttributeSet attrs, final int defStyle, final ArrayList<TextView> wordViews, final ArrayList<View> dividerViews, final ArrayList<TextView> debugInfoViews) { mWordViews = wordViews;/*from w ww .j a v a 2 s . co m*/ mDividerViews = dividerViews; mDebugInfoViews = debugInfoViews; final TextView wordView = wordViews.get(0); final View dividerView = dividerViews.get(0); mPadding = wordView.getCompoundPaddingLeft() + wordView.getCompoundPaddingRight(); dividerView.measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); mDividerWidth = dividerView.getMeasuredWidth(); final Resources res = wordView.getResources(); mSuggestionsStripHeight = res.getDimensionPixelSize(R.dimen.config_suggestions_strip_height); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SuggestionStripView, defStyle, R.style.SuggestionStripView); mSuggestionStripOptions = a.getInt(R.styleable.SuggestionStripView_suggestionStripOptions, 0); mAlphaObsoleted = ResourceUtils.getFraction(a, R.styleable.SuggestionStripView_alphaObsoleted, 1.0f); mColorValidTypedWord = a.getColor(R.styleable.SuggestionStripView_colorValidTypedWord, 0); mColorTypedWord = a.getColor(R.styleable.SuggestionStripView_colorTypedWord, 0); mColorAutoCorrect = a.getColor(R.styleable.SuggestionStripView_colorAutoCorrect, 0); mColorSuggested = a.getColor(R.styleable.SuggestionStripView_colorSuggested, 0); mSuggestionsCountInStrip = a.getInt(R.styleable.SuggestionStripView_suggestionsCountInStrip, DEFAULT_SUGGESTIONS_COUNT_IN_STRIP); mCenterSuggestionWeight = ResourceUtils.getFraction(a, R.styleable.SuggestionStripView_centerSuggestionPercentile, DEFAULT_CENTER_SUGGESTION_PERCENTILE); mMaxMoreSuggestionsRow = a.getInt(R.styleable.SuggestionStripView_maxMoreSuggestionsRow, DEFAULT_MAX_MORE_SUGGESTIONS_ROW); mMinMoreSuggestionsWidth = ResourceUtils.getFraction(a, R.styleable.SuggestionStripView_minMoreSuggestionsWidth, 1.0f); a.recycle(); mMoreSuggestionsHint = getMoreSuggestionsHint(res, res.getDimension(R.dimen.config_more_suggestions_hint_text_size), mColorAutoCorrect); mCenterPositionInStrip = mSuggestionsCountInStrip / 2; // Assuming there are at least three suggestions. Also, note that the suggestions are // laid out according to script direction, so this is left of the center for LTR scripts // and right of the center for RTL scripts. mTypedWordPositionWhenAutocorrect = mCenterPositionInStrip - 1; mMoreSuggestionsBottomGap = res.getDimensionPixelOffset(R.dimen.config_more_suggestions_bottom_gap); mMoreSuggestionsRowHeight = res.getDimensionPixelSize(R.dimen.config_more_suggestions_row_height); }
From source file:com.maedi.user.godok.v1.viewpagerindicator.CirclePageIndicator.java
@SuppressWarnings("deprecation") public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;/*w w w . ja v a 2 s . c o m*/ //Load defaults from resources final Resources res = getResources(); final int defaultPageColor = res .getColor(com.viewpagerindicator.R.color.default_circle_indicator_page_color); final int defaultFillColor = res .getColor(com.viewpagerindicator.R.color.default_circle_indicator_fill_color); final int defaultOrientation = res .getInteger(com.viewpagerindicator.R.integer.default_circle_indicator_orientation); final int defaultStrokeColor = res .getColor(com.viewpagerindicator.R.color.default_circle_indicator_stroke_color); final float defaultStrokeWidth = res .getDimension(com.viewpagerindicator.R.dimen.default_circle_indicator_stroke_width); final float defaultRadius = res .getDimension(com.viewpagerindicator.R.dimen.default_circle_indicator_radius); final boolean defaultCentered = res .getBoolean(com.viewpagerindicator.R.bool.default_circle_indicator_centered); final boolean defaultSnap = res.getBoolean(com.viewpagerindicator.R.bool.default_circle_indicator_snap); //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, com.viewpagerindicator.R.styleable.CirclePageIndicator, defStyle, 0); mCentered = a.getBoolean(com.viewpagerindicator.R.styleable.CirclePageIndicator_centered, defaultCentered); mOrientation = a.getInt(com.viewpagerindicator.R.styleable.CirclePageIndicator_android_orientation, defaultOrientation); mPaintPageFill.setStyle(Style.FILL); mPaintPageFill.setColor( a.getColor(com.viewpagerindicator.R.styleable.CirclePageIndicator_pageColor, defaultPageColor)); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor( a.getColor(com.viewpagerindicator.R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor)); mPaintStroke.setStrokeWidth(a.getDimension( com.viewpagerindicator.R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth)); mPaintFill.setStyle(Style.FILL); mPaintFill.setColor( a.getColor(com.viewpagerindicator.R.styleable.CirclePageIndicator_fillColor, defaultFillColor)); mRadius = a.getDimension(com.viewpagerindicator.R.styleable.CirclePageIndicator_radius, defaultRadius); mSnap = a.getBoolean(com.viewpagerindicator.R.styleable.CirclePageIndicator_snap, defaultSnap); Drawable background = a .getDrawable(com.viewpagerindicator.R.styleable.CirclePageIndicator_android_background); if (background != null) { setBackgroundDrawable(background); } a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }