List of usage examples for android.content.res TypedArray getDimensionPixelSize
public int getDimensionPixelSize(@StyleableRes int index, int defValue)
From source file:com.ninghoo.beta17ma27.weydio2.FastScrollView.FastScroller.java
public FastScroller(Context context, FastScrollRecyclerView recyclerView, AttributeSet attrs) { Resources resources = context.getResources(); mRecyclerView = recyclerView;//from w w w . j a v a 2 s . c om mPopup = new FastScrollPopup(resources, recyclerView); // fast? mThumbHeight = Utils.toPixels(resources, 310); mWidth = Utils.toPixels(resources, 3); // 2???fastscroll mTouchInset = Utils.toPixels(resources, -24); mThumb = new Paint(Paint.ANTI_ALIAS_FLAG); mTrack = new Paint(Paint.ANTI_ALIAS_FLAG); TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.FastScrollRecyclerView, 0, 0); try { mAutoHideEnabled = typedArray.getBoolean(R.styleable.FastScrollRecyclerView_fastScrollAutoHide, true); mAutoHideDelay = typedArray.getInteger(R.styleable.FastScrollRecyclerView_fastScrollAutoHideDelay, DEFAULT_AUTO_HIDE_DELAY); int trackColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollTrackColor, 0x1f000000); int thumbColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollThumbColor, 0xff000000); int popupBgColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollPopupBgColor, 0xff000000); int popupTextColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollPopupTextColor, 0xffffffff); int popupTextSize = typedArray.getDimensionPixelSize( R.styleable.FastScrollRecyclerView_fastScrollPopupTextSize, Utils.toScreenPixels(resources, 56)); int popupBackgroundSize = typedArray.getDimensionPixelSize( R.styleable.FastScrollRecyclerView_fastScrollPopupBackgroundSize, Utils.toPixels(resources, 88)); mTrack.setColor(trackColor); mThumb.setColor(thumbColor); mPopup.setBgColor(popupBgColor); mPopup.setTextColor(popupTextColor); mPopup.setTextSize(popupTextSize); mPopup.setBackgroundSize(popupBackgroundSize); } finally { typedArray.recycle(); } mHideRunnable = new Runnable() { @Override public void run() { if (!mIsDragging) { if (mAutoHideAnimator != null) { mAutoHideAnimator.cancel(); } mAutoHideAnimator = ObjectAnimator.ofInt(FastScroller.this, "offsetX", (Utils.isRtl(mRecyclerView.getResources()) ? -1 : 1) * mWidth); mAutoHideAnimator.setInterpolator(new FastOutLinearInInterpolator()); // mAutoHideAnimator.setDuration(200); mAutoHideAnimator.start(); } } }; mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); show(); } }); if (mAutoHideEnabled) { postAutoHideDelayed(); } }
From source file:com.adherence.adherence.SwipeRevealLayout.java
private void init(Context context, AttributeSet attrs) { if (attrs != null && context != null) { TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.SwipeRevealLayout, 0, 0); mDragEdge = a.getInteger(R.styleable.SwipeRevealLayout_dragEdge, DRAG_EDGE_LEFT); mMinFlingVelocity = a.getInteger(R.styleable.SwipeRevealLayout_flingVelocity, DEFAULT_MIN_FLING_VELOCITY); mMode = a.getInteger(R.styleable.SwipeRevealLayout_mode, MODE_NORMAL); mMinDistRequestDisallowParent = a.getDimensionPixelSize( R.styleable.SwipeRevealLayout_minDistRequestDisallowParent, dpToPx(DEFAULT_MIN_DIST_REQUEST_DISALLOW_PARENT)); }/*from w ww . ja v a 2s . c o m*/ mDragHelper = ViewDragHelper.create(this, 1.0f, mDragHelperCallback); mDragHelper.setEdgeTrackingEnabled(ViewDragHelper.EDGE_ALL); mGestureDetector = new GestureDetectorCompat(context, mGestureListener); }
From source file:com.libs.golomb.extendedrecyclerview.Scroller.FastScroller2.java
public FastScroller2(Context context, FastScrollRecyclerView2 recyclerView, AttributeSet attrs) { Resources resources = context.getResources(); mRecyclerView = recyclerView;//from w w w. j a va 2 s .c o m mPopup = new FastScrollPopup2(resources, recyclerView); mThumbHeight = Utils.toPixels(resources, 48); mWidth = Utils.toPixels(resources, 8); mTouchInset = Utils.toPixels(resources, -24); mThumb = new Paint(Paint.ANTI_ALIAS_FLAG); mTrack = new Paint(Paint.ANTI_ALIAS_FLAG); TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.FastScrollRecyclerView, 0, 0); try { mAutoHideEnabled = typedArray.getBoolean(R.styleable.FastScrollRecyclerView_fastScrollAutoHide, true); mAutoHideDelay = typedArray.getInteger(R.styleable.FastScrollRecyclerView_fastScrollAutoHideDelay, DEFAULT_AUTO_HIDE_DELAY); int trackColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollTrackColor, 0x1f000000); int thumbColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollThumbColor, 0xff000000); int popupBgColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollPopupBgColor, 0xff000000); int popupTextColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollPopupTextColor, 0xffffffff); int popupTextSize = typedArray.getDimensionPixelSize( R.styleable.FastScrollRecyclerView_fastScrollPopupTextSize, Utils.toScreenPixels(resources, 56)); int popupBackgroundSize = typedArray.getDimensionPixelSize( R.styleable.FastScrollRecyclerView_fastScrollPopupBackgroundSize, Utils.toPixels(resources, 88)); mTrack.setColor(trackColor); mThumb.setColor(thumbColor); mPopup.setBgColor(popupBgColor); mPopup.setTextColor(popupTextColor); mPopup.setTextSize(popupTextSize); mPopup.setBackgroundSize(popupBackgroundSize); } finally { typedArray.recycle(); } mHideRunnable = new Runnable() { @Override public void run() { if (!mIsDragging) { if (mAutoHideAnimator != null) { mAutoHideAnimator.cancel(); } mAutoHideAnimator = ObjectAnimator.ofInt(FastScroller2.this, "offsetX", (Utils.isRtl(mRecyclerView.getResources()) ? -1 : 1) * mWidth); mAutoHideAnimator.setInterpolator(new FastOutLinearInInterpolator()); mAutoHideAnimator.setDuration(200); mAutoHideAnimator.start(); } } }; mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { //TODO Log.d("TGolomb", "onScrolled: " + scrollY.addAndGet(dy)); show(); } }); if (mAutoHideEnabled) { postAutoHideDelayed(); } }
From source file:com.cqyw.smart.widget.viewpaper.PagerSlidingTabStrip.java
public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setFillViewport(true);//from www. j a v a 2 s. co m setWillNotDraw(false); tabsContainer = new LinearLayout(context); tabsContainer.setOrientation(LinearLayout.HORIZONTAL); tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); addView(tabsContainer); DisplayMetrics dm = getResources().getDisplayMetrics(); scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm); indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, indicatorHeight, dm); underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, underlineHeight, dm); dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm); tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm); dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm); // get system attrs (android:textSize and android:textColor) TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); a.recycle(); // get custom attrs a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip); indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor); underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor); dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor); checkedTextColor = a.getResourceId(R.styleable.TwoTextView_ttLeftTextColor, R.color.theme_color); unCheckedTextColor = a.getResourceId(R.styleable.TwoTextView_ttLeftTextColor, R.color.white); indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight, indicatorHeight); underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight, underlineHeight); dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding, dividerPadding); tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding); scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset); textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps); a.recycle(); rectPaint = new Paint(); rectPaint.setAntiAlias(true); rectPaint.setStyle(Style.FILL); dividerPaint = new Paint(); dividerPaint.setAntiAlias(true); dividerPaint.setStrokeWidth(dividerWidth); tabViewLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f); if (locale == null) { locale = getResources().getConfiguration().locale; } }
From source file:com.commonsware.cwac.crossport.design.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_android_backgroundTint); mBackgroundTintMode = ViewUtils/*from www . j av a 2s . c o m*/ .parseTintMode(a.getInt(R.styleable.FloatingActionButton_android_backgroundTintMode, -1), null); mRippleColor = a.getColor(R.styleable.FloatingActionButton_rippleColor, 0); mSize = a.getInt(R.styleable.FloatingActionButton_fabSize, SIZE_AUTO); mCustomSize = a.getDimensionPixelSize(R.styleable.FloatingActionButton_fabCustomSize, 0); mBorderWidth = a.getDimensionPixelSize(R.styleable.FloatingActionButton_borderWidth, 0); final float elevation = a.getDimension(R.styleable.FloatingActionButton_android_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); mImageHelper.loadFromAttributes(attrs, defStyleAttr); */ mMaxImageSize = (int) getResources().getDimension(R.dimen.design_fab_image_size); getImpl().setBackgroundDrawable(mBackgroundTint, mBackgroundTintMode, mRippleColor, mBorderWidth); getImpl().setElevation(elevation); getImpl().setPressedTranslationZ(pressedTranslationZ); }
From source file:com.aqtx.app.common.ui.viewpager.PagerSlidingTabStrip.java
public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setFillViewport(true);//from ww w.j a va2s . c om setWillNotDraw(false); tabsContainer = new LinearLayout(context); tabsContainer.setOrientation(LinearLayout.HORIZONTAL); tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); addView(tabsContainer); DisplayMetrics dm = getResources().getDisplayMetrics(); scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm); indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm); underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, underlineHeight, dm); dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm); tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm); dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm); // get system attrs (android:textSize and android:textColor) TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); a.recycle(); // get custom attrs a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip); indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor); underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor); dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor); checkedTextColor = a.getResourceId(R.styleable.TwoTextView_ttLeftTextColor, R.color.color_blue_0888ff); unCheckedTextColor = a.getResourceId(R.styleable.TwoTextView_ttLeftTextColor, R.color.action_bar_tittle_color_555555); indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight, indicatorHeight); underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight, underlineHeight); dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding, dividerPadding); tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding); scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset); textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps); a.recycle(); rectPaint = new Paint(); rectPaint.setAntiAlias(true); rectPaint.setStyle(Style.FILL); dividerPaint = new Paint(); dividerPaint.setAntiAlias(true); dividerPaint.setStrokeWidth(dividerWidth); tabViewLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f); if (locale == null) { locale = getResources().getConfiguration().locale; } }
From source file:com.plugin.weight.ripple.RippleLayoutView.java
/** * Method that initializes all fields and sets listeners * * @param context Context used to create this view * @param attrs Attribute used to initialize fields *//*from ww w .ja va 2 s. c o m*/ private void init(final Context context, final AttributeSet attrs) { if (isInEditMode()) return; final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RippleLayoutView); rippleColor = typedArray.getColor(R.styleable.RippleLayoutView_rv_color, ContextCompat.getColor(context, R.color.rippelColor));//? rippleType = typedArray.getInt(R.styleable.RippleLayoutView_rv_type, 0);//? hasToZoom = typedArray.getBoolean(R.styleable.RippleLayoutView_rv_zoom, false);//? isCentered = typedArray.getBoolean(R.styleable.RippleLayoutView_rv_centered, false);//? rippleDuration = typedArray.getInteger(R.styleable.RippleLayoutView_rv_rippleDuration, rippleDuration); frameRate = typedArray.getInteger(R.styleable.RippleLayoutView_rv_framerate, frameRate); rippleAlpha = typedArray.getInteger(R.styleable.RippleLayoutView_rv_alpha, rippleAlpha); ripplePadding = typedArray.getDimensionPixelSize(R.styleable.RippleLayoutView_rv_ripplePadding, 0); canvasHandler = new Handler(); zoomScale = typedArray.getFloat(R.styleable.RippleLayoutView_rv_zoomScale, 1.03f); zoomDuration = typedArray.getInt(R.styleable.RippleLayoutView_rv_zoomDuration, 200); typedArray.recycle(); paint = new Paint(); paint.setAntiAlias(true); paint.setStyle(Paint.Style.FILL); paint.setColor(rippleColor); paint.setAlpha(rippleAlpha); this.setWillNotDraw(false); gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() { @Override public void onLongPress(MotionEvent event) { super.onLongPress(event); animateRipple(event); sendClickEvent(true); } @Override public boolean onSingleTapConfirmed(MotionEvent e) { return true; } @Override public boolean onSingleTapUp(MotionEvent e) { return true; } }); this.setDrawingCacheEnabled(true); this.setClickable(true); }
From source file:com.fuzz.indicator.CutoutViewIndicator.java
@SuppressWarnings("ResourceType") protected void init(Context context, AttributeSet attrs, int defStyleAttr) { if (attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CutoutViewIndicator); setIndicatorDrawableId(a.getResourceId(R.styleable.CutoutViewIndicator_rcv_drawable, 0)); setInternalSpacing(a.getDimensionPixelOffset(R.styleable.CutoutViewIndicator_rcv_internal_margin, 0)); // The superclass will have resolved orientation by now. if (getOrientation() == HORIZONTAL) { setPerpendicularLength(/*from w w w . j ava2s. com*/ a.getDimensionPixelSize(R.styleable.CutoutViewIndicator_rcv_height, WRAP_CONTENT)); setCellLength(a.getDimensionPixelOffset(R.styleable.CutoutViewIndicator_rcv_width, WRAP_CONTENT)); } else { setPerpendicularLength( a.getDimensionPixelSize(R.styleable.CutoutViewIndicator_rcv_width, WRAP_CONTENT)); setCellLength(a.getDimensionPixelOffset(R.styleable.CutoutViewIndicator_rcv_height, WRAP_CONTENT)); } if (isInEditMode()) { editModePageCount = a.getInteger(R.styleable.CutoutViewIndicator_rcv_tools_indicator_count, 2); } String generatorName = a.getString(R.styleable.CutoutViewIndicator_rcv_generator_class_name); if (generatorName != null) { CCGFactory.constructGeneratorFrom(context, attrs, defStyleAttr, generatorName, new ConstructorCallback() { @Override public void onGenerated(@NonNull CutoutCellGenerator generated) { CutoutViewIndicator.this.generator = generated; } @Override public void onFailed(@NonNull String message) { if (!message.isEmpty()) { Log.e(TAG, message); if (isInEditMode()) { String tag = "resources.invalid"; logger.logToLayoutLib(tag, message); } } } }); } setCellBackgroundId(a.getResourceId(R.styleable.CutoutViewIndicator_rcv_drawable_unselected, 0)); a.recycle(); } if (isInEditMode()) { setStateProxy(EDIT_MODE_PROXY); } }
From source file:cn.edu.zafu.easemob.imagecoverflow.CoverFlowView.java
private void initAttributes(Context context, AttributeSet attrs) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ImageCoverFlowView); int totalVisibleChildren = a.getInt(R.styleable.ImageCoverFlowView_visibleImage, 3); setVisibleImage(totalVisibleChildren); reflectHeightFraction = a.getFraction(R.styleable.ImageCoverFlowView_reflectionHeight, 100, 0, 0.0f); if (reflectHeightFraction > 100) { reflectHeightFraction = 100;/*w w w. j a va2s.com*/ } 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(); }
From source file:com.bridgelabz.appystore.librarycarosal.CoverFlowView.java
private void initAttributes(Context context, AttributeSet attrs) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ImageCoverFlowView); int totalVisibleChildren = a.getInt(R.styleable.ImageCoverFlowView_visibleImage, 11); setVisibleImage(totalVisibleChildren); reflectHeightFraction = a.getFraction(R.styleable.ImageCoverFlowView_reflectionHeight, 100, 0, 0.0f); if (reflectHeightFraction > 100) { reflectHeightFraction = 100;/*from w w w. j a va 2 s. c o m*/ } 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(); }