List of usage examples for android.content.res TypedArray getInt
public int getInt(@StyleableRes int index, int defValue)
From source file:com.github.ppamorim.dragger.DraggerView.java
private void initializeAttributes(AttributeSet attrs) { TypedArray attributes = getContext().obtainStyledAttributes(attrs, R.styleable.dragger_layout); this.dragLimit = attributes.getFloat(R.styleable.dragger_layout_drag_limit, DEFAULT_DRAG_LIMIT); this.dragPosition = DraggerPosition.getDragPosition( attributes.getInt(R.styleable.dragger_layout_drag_position, DEFAULT_DRAG_POSITION)); this.tension = attributes.getInteger(R.styleable.dragger_layout_tension, DEFAULT_TENSION); this.friction = attributes.getInteger(R.styleable.dragger_layout_friction, DEFAULT_FRICTION); this.attributes = attributes; }
From source file:com.gitstudy.rili.liarbry.CalendarLayout.java
public CalendarLayout(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(LinearLayout.VERTICAL); TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.CalendarLayout); mContentViewId = array.getResourceId(R.styleable.CalendarLayout_calendar_content_view_id, 0); mDefaultStatus = array.getInt(R.styleable.CalendarLayout_default_status, STATUS_EXPAND); mCalendarShowMode = array.getInt(R.styleable.CalendarLayout_calendar_show_mode, CALENDAR_SHOW_MODE_BOTH_MONTH_WEEK_VIEW); mGestureMode = array.getInt(R.styleable.CalendarLayout_gesture_mode, GESTURE_MODE_DEFAULT); array.recycle();//from w ww .j a v a 2 s. co m mVelocityTracker = VelocityTracker.obtain(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = configuration.getScaledTouchSlop(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); }
From source file:com.dragon.lib.IndicatorView.java
private void init(AttributeSet attrs, int defStyle) { final Resources res = getResources(); final int defaultIndicatorSelectedColor = res.getColor(R.color.indicator_selected); final int defaultIndicatorUnseletedColor = res.getColor(R.color.indicator_unselected); final float defaultWidth = res.getDimension(R.dimen.indicator_width); final float defaultIndicatorHeight = res.getDimension(R.dimen.indicator_line_height); final int defaultIndicatorBackground = res.getColor(R.color.indicator_backgroup); final int defaultPosition = CENTER; mIndicatorHeight = defaultIndicatorHeight; mIndicatorPaint.setStyle(Paint.Style.FILL); TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.ScrollImageView); mIndicatorSelectedColor = a.getColor(R.styleable.ScrollImageView_indicatorSelectedColor, defaultIndicatorSelectedColor); mIndicatorUnselectedColor = a.getColor(R.styleable.ScrollImageView_indicatorUnselectedColor, defaultIndicatorUnseletedColor); mIndicatorType = a.getInt(R.styleable.ScrollImageView_indicatorType, CIRCLE); mIndicatorBackground = a.getResourceId(R.styleable.ScrollImageView_indicatorBackground, defaultIndicatorBackground); mIndicatorPosition = a.getInt(R.styleable.ScrollImageView_indicatorPosition, defaultPosition); mIndicatorWidth = a.getDimension(R.styleable.ScrollImageView_indicatorWidth, defaultWidth); mIndicatorHeight = a.getDimension(R.styleable.ScrollImageView_indicatorHeight, defaultIndicatorHeight); a.recycle();/*from ww w.j a va2 s . c o m*/ mIndicatorPaint.setStrokeWidth(mIndicatorHeight); }
From source file:com.fortysevendeg.swipelistview.ExpandableSwipeListView.java
/** * Init ListView// www . j a v a 2 s .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 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.ExpandableSwipeListView); swipeMode = styled.getInt(R.styleable.ExpandableSwipeListView_swipeMode, SWIPE_MODE_BOTH); swipeActionLeft = styled.getInt(R.styleable.ExpandableSwipeListView_swipeActionLeft, SWIPE_ACTION_REVEAL); swipeActionRight = styled.getInt(R.styleable.ExpandableSwipeListView_swipeActionRight, SWIPE_ACTION_REVEAL); swipeOffsetLeft = styled.getDimension(R.styleable.ExpandableSwipeListView_swipeOffsetLeft, 0); swipeOffsetRight = styled.getDimension(R.styleable.ExpandableSwipeListView_swipeOffsetRight, 0); swipeOpenOnLongPress = styled.getBoolean(R.styleable.ExpandableSwipeListView_swipeOpenOnLongPress, true); swipeAnimationTime = styled.getInteger(R.styleable.ExpandableSwipeListView_swipeAnimationTime, 0); swipeCloseAllItemsWhenMoveList = styled .getBoolean(R.styleable.ExpandableSwipeListView_swipeCloseAllItemsWhenMoveList, true); swipeDrawableChecked = styled.getResourceId(R.styleable.ExpandableSwipeListView_swipeDrawableChecked, 0); swipeDrawableUnchecked = styled .getResourceId(R.styleable.ExpandableSwipeListView_swipeDrawableUnchecked, 0); swipeFrontView = styled.getResourceId(R.styleable.ExpandableSwipeListView_swipeFrontView, 0); swipeBackView = styled.getResourceId(R.styleable.ExpandableSwipeListView_swipeBackView, 0); swipeGroupView = styled.getResourceId(R.styleable.ExpandableSwipeListView_swipeGroupView, 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 ExpandableSwipeListViewTouchListener(this, swipeFrontView, swipeBackView, swipeGroupView); 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.lokiy.widget.BannerView.java
public BannerView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.BannerView); isShowIndicator = a.getBoolean(R.styleable.BannerView_showIndicator, true); mIndicatorId = a.getResourceId(R.styleable.BannerView_indicator, 0); isCorner = a.getBoolean(R.styleable.BannerView_corner, false); mRectRoundRadius = a.getDimensionPixelOffset(R.styleable.BannerView_cornerRadii, 0); mPageMargin = a.getDimensionPixelSize(R.styleable.BannerView_pageMargin, 0); int mIndicatorGravity = a.getInt(R.styleable.BannerView_indicator_gravity, Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM); a.recycle();//from w w w . ja v a 2 s. c om mViewPager = new XViewPager(getContext(), null); mViewPager.setPageMargin(mPageMargin); setClipChildren(false); mAdapter = new BannerAdapter(); //noinspection deprecation mViewPager.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageScrolled(int arg0, float arg1, int arg2) { } @Override public void onPageSelected(int position) { position = position % mAdapter.getRealCount(); if (isShowIndicator) { vRadioGroup.check(position); } if (onPageSelectedListener != null) { onPageSelectedListener.onPageSelected(position, mAdapter.mBannerList.get(position)); } } @Override public void onPageScrollStateChanged(int position) { } }); mViewPager.setAdapter(mAdapter); addView(mViewPager, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); if (isShowIndicator) { vRadioGroup = new RadioGroup(getContext()); LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.gravity = mIndicatorGravity; vRadioGroup.setGravity(Gravity.CENTER); vRadioGroup.setOrientation(LinearLayout.HORIZONTAL); addView(vRadioGroup, params); } }
From source file:com.example.FilteredActivityChooserView.java
/** * Create a new instance./*from w w w.j a va2 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 FilteredActivityChooserView(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); mActivityChooserContentBackground = mActivityChooserContent.getBackground(); mDefaultActivityButton = (FrameLayout) findViewById(R.id.default_activity_button); mDefaultActivityButton.setOnClickListener(mCallbacks); mDefaultActivityButton.setOnLongClickListener(mCallbacks); mDefaultActivityButtonImage = (ImageView) mDefaultActivityButton.findViewById(R.id.image); 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:android.support.designox.widget.FloatingActionButton.java
public FloatingActionButton(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); ThemeUtils.checkAppCompatTheme(context); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionButton, defStyleAttr, R.style.Widget_Design_FloatingActionButton); mBackgroundTint = a.getColorStateList(R.styleable.FloatingActionButton_backgroundTint_ox); mBackgroundTintMode = parseTintMode(a.getInt(R.styleable.FloatingActionButton_backgroundTintMode_ox, -1), null);/*from w ww . j a v a 2s . c o m*/ mRippleColor = a.getColor(R.styleable.FloatingActionButton_rippleColor, 0); mSize = a.getInt(R.styleable.FloatingActionButton_fabSize_ox, SIZE_NORMAL); mBorderWidth = a.getDimensionPixelSize(R.styleable.FloatingActionButton_borderWidth, 0); final float elevation = a.getDimension(R.styleable.FloatingActionButton_elevation, 0f); final float pressedTranslationZ = a.getDimension(R.styleable.FloatingActionButton_pressedTranslationZ, 0f); mCompatPadding = a.getBoolean(R.styleable.FloatingActionButton_useCompatPadding, false); a.recycle(); mImageHelper = new AppCompatImageHelper(this, AppCompatDrawableManager.get()); mImageHelper.loadFromAttributes(attrs, defStyleAttr); final int maxImageSize = (int) getResources().getDimension(R.dimen.design_fab_image_size); mImagePadding = (getSizeDimension() - maxImageSize) / 2; getImpl().setBackgroundDrawable(mBackgroundTint, mBackgroundTintMode, mRippleColor, mBorderWidth); getImpl().setElevation(elevation); getImpl().setPressedTranslationZ(pressedTranslationZ); getImpl().updatePadding(); }
From source file:com.coinomi.wallet.ui.widget.ActivityChooserView.java
/** * Create a new instance.// w w w . ja v a 2 s . c om * * @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); mActivityChooserContentBackground = mActivityChooserContent.getBackground(); mDefaultActivityButton = (FrameLayout) findViewById(R.id.default_activity_button); mDefaultActivityButton.setOnClickListener(mCallbacks); mDefaultActivityButton.setOnLongClickListener(mCallbacks); mDefaultActivityButtonImage = (ImageView) mDefaultActivityButton.findViewById(R.id.image); 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.albedinsky.android.support.ui.widget.FrameLayoutWidget.java
/** * Called from the constructor to process tint values for this view. <b>Note</b>, that for * {@link android.os.Build.VERSION_CODES#LOLLIPOP LOLLIPOP} is this call ignored. * * @param context The context passed to constructor. * @param typedArray TypedArray obtained for styleable attributes specific for this view. *///ww w . j av a 2 s . c om @SuppressWarnings("All") private void processTintValues(Context context, TypedArray typedArray) { // Do not handle for LOLLIPOP. if (UiConfig.LOLLIPOP) { return; } this.ensureTintInfo(); // Get tint colors. if (typedArray.hasValue(R.styleable.Ui_ViewGroup_uiBackgroundTint)) { mTintInfo.backgroundTintList = typedArray.getColorStateList(R.styleable.Ui_ViewGroup_uiBackgroundTint); } // Get tint modes. mTintInfo.backgroundTintMode = TintManager.parseTintMode( typedArray.getInt(R.styleable.Ui_ViewGroup_uiBackgroundTintMode, 0), mTintInfo.backgroundTintList != null ? PorterDuff.Mode.SRC_IN : null); // If there is no tint mode specified within style/xml do not tint at all. if (mTintInfo.backgroundTintMode == null) { mTintInfo.backgroundTintList = null; } mTintInfo.hasBackgroundTintList = mTintInfo.backgroundTintList != null; mTintInfo.hasBackgroundTinMode = mTintInfo.backgroundTintMode != null; }
From source file:com.haibin.calendarview.CalendarView.java
public CalendarView(@NonNull Context context, @Nullable AttributeSet attrs) { super(context, attrs); TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.CalendarView); mCurDayColor = array.getColor(R.styleable.CalendarView_current_day_color, Color.RED); mSchemeThemeColor = array.getColor(R.styleable.CalendarView_scheme_theme_color, Color.RED); mWeekBackground = array.getColor(R.styleable.CalendarView_week_background, Color.WHITE); mWeekTextColor = array.getColor(R.styleable.CalendarView_week_text_color, Color.RED); mSelectedColor = array.getColor(R.styleable.CalendarView_selected_color, 0x50CFCFCF); mSelectedTextColor = array.getColor(R.styleable.CalendarView_selected_text_color, 0xFF111111); mMinYear = array.getInt(R.styleable.CalendarView_min_year, 2010); mMaxYear = array.getInt(R.styleable.CalendarView_max_year, 2050); mScheme = array.getString(R.styleable.CalendarView_scheme_text); if (mMinYear <= 1900) mMaxYear = 1900;// w ww . ja v a 2 s . com if (mMaxYear >= 2099) mMaxYear = 2099; array.recycle(); init(context); }