Java Code Examples for android.graphics.Paint#setStrokeWidth()
The following examples show how to use
android.graphics.Paint#setStrokeWidth() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Clock.java From Clock-view with Apache License 2.0 | 6 votes |
private void onPreDraw(Canvas canvas) { this.size = getHeight() > getWidth() ? getWidth() : getHeight(); this.centerX = size / 2; this.centerY = size / 2; this.radius = (int) ((this.size * (1 - DEFAULT_BORDER_THICKNESS)) / 2); this.defaultThickness = this.size * DEFAULT_BORDER_THICKNESS; this.defaultRectF = new RectF( defaultThickness, defaultThickness, this.size - defaultThickness, this.size - defaultThickness); Paint paint = new Paint(); paint.setColor(Color.BLUE); paint.setStyle(Paint.Style.STROKE); paint.setAntiAlias(true); paint.setStrokeWidth(defaultThickness); //canvas.drawRect(new Rect(0, 0, getWidth(), getHeight()), paint); //canvas.drawCircle(centerX, centerY, radius, paint); }
Example 2
Source File: MaskView.java From Tess-TwoDemo with Apache License 2.0 | 5 votes |
private void initPaint(){ mLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mLinePaint.setColor(lineColor); mLinePaint.setStyle(Paint.Style.STROKE); mLinePaint.setStrokeWidth(lineStroke); mLinePaint.setAlpha(lineAlpha); //绘制四周区域 mAreaPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mAreaPaint.setColor(areaBgColor); mAreaPaint.setStyle(Paint.Style.FILL); mAreaPaint.setAlpha(areaBgAlpha); }
Example 3
Source File: GridSpacingItemDecoration.java From a with GNU General Public License v3.0 | 5 votes |
public GridSpacingItemDecoration(int space, int color) { this.space = space; this.color = color; mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint.setColor(color); mPaint.setStyle(Paint.Style.FILL); mPaint.setStrokeWidth(space * 2); }
Example 4
Source File: ScannerOverlayView.java From zephyr with MIT License | 5 votes |
private void init() { setWillNotDraw(false); mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint.setColor(ContextCompat.getColor(getContext(), R.color.accent)); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeWidth(10); }
Example 5
Source File: SlidingTabStrip.java From android-tv-leanback with Apache License 2.0 | 5 votes |
SlidingTabStrip(Context context, AttributeSet attrs) { super(context, attrs); setWillNotDraw(false); final float density = getResources().getDisplayMetrics().density; TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(R.attr.colorForeground, outValue, true); final int themeForegroundColor = outValue.data; mDefaultBottomBorderColor = setColorAlpha(themeForegroundColor, DEFAULT_BOTTOM_BORDER_COLOR_ALPHA); mDefaultTabColorizer = new SimpleTabColorizer(); mDefaultTabColorizer.setIndicatorColors(DEFAULT_SELECTED_INDICATOR_COLOR); mDefaultTabColorizer.setDividerColors(setColorAlpha(themeForegroundColor, DEFAULT_DIVIDER_COLOR_ALPHA)); mBottomBorderThickness = (int) (DEFAULT_BOTTOM_BORDER_THICKNESS_DIPS * density); mBottomBorderPaint = new Paint(); mBottomBorderPaint.setColor(mDefaultBottomBorderColor); mSelectedIndicatorThickness = (int) (SELECTED_INDICATOR_THICKNESS_DIPS * density); mSelectedIndicatorPaint = new Paint(); mDividerHeight = DEFAULT_DIVIDER_HEIGHT; mDividerPaint = new Paint(); mDividerPaint.setStrokeWidth((int) (DEFAULT_DIVIDER_THICKNESS_DIPS * density)); }
Example 6
Source File: SlidingTabStrip.java From android-tv-leanback with Apache License 2.0 | 5 votes |
SlidingTabStrip(Context context, AttributeSet attrs) { super(context, attrs); setWillNotDraw(false); final float density = getResources().getDisplayMetrics().density; TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(R.attr.colorForeground, outValue, true); final int themeForegroundColor = outValue.data; mDefaultBottomBorderColor = setColorAlpha(themeForegroundColor, DEFAULT_BOTTOM_BORDER_COLOR_ALPHA); mDefaultTabColorizer = new SimpleTabColorizer(); mDefaultTabColorizer.setIndicatorColors(DEFAULT_SELECTED_INDICATOR_COLOR); mDefaultTabColorizer.setDividerColors(setColorAlpha(themeForegroundColor, DEFAULT_DIVIDER_COLOR_ALPHA)); mBottomBorderThickness = (int) (DEFAULT_BOTTOM_BORDER_THICKNESS_DIPS * density); mBottomBorderPaint = new Paint(); mBottomBorderPaint.setColor(mDefaultBottomBorderColor); mSelectedIndicatorThickness = (int) (SELECTED_INDICATOR_THICKNESS_DIPS * density); mSelectedIndicatorPaint = new Paint(); mDividerHeight = DEFAULT_DIVIDER_HEIGHT; mDividerPaint = new Paint(); mDividerPaint.setStrokeWidth((int) (DEFAULT_DIVIDER_THICKNESS_DIPS * density)); }
Example 7
Source File: SpringView.java From GifAssistant with Apache License 2.0 | 5 votes |
private void init(){ setAlpha(0); headPoint = new Point(); footPoint = new Point(); path = new Path(); paint = new Paint(); paint.setAntiAlias(true); paint.setStyle(Paint.Style.FILL_AND_STROKE); paint.setStrokeWidth(1); }
Example 8
Source File: WaveLoadingView.java From ReadMark with Apache License 2.0 | 5 votes |
private void init(Context context, AttributeSet attrs, int defStyleAttr){ mContext = context; mMinumWidth = dp2px(48); mMinumHeight = dp2px(48); TypedArray attributes = mContext.obtainStyledAttributes(attrs, R.styleable.WaveLoadingView, defStyleAttr, 0); mType = attributes.getInteger(R.styleable.WaveLoadingView_wlv_shapeType, DEFAULT_WAVE_SHAPE); mWaveColor = attributes.getInteger(R.styleable.WaveLoadingView_wlv_waveColor, DEFAULT_WAVE_COLOR); //最后范围1~2个宽度 float lengthRatio = attributes.getFloat(R.styleable.WaveLoadingView_wlv_waveLengthRation, DEFAULT_WAVE_LENGTH_RATIO); mWaveLengthRatio = 1.0f + 1.0f * (lengthRatio > 1.0f ? 1.0f : lengthRatio); //最后范围0.1~0.4个高度 float ampRatio = attributes.getFloat(R.styleable.WaveLoadingView_wlv_waveAmplitudeRatio, DEFAULT_AMPLITUDE_RATIO); mWaveAmplitudeRatio = 0.5f + 0.5f * (ampRatio > 1.0f ? 1.0f : ampRatio); mBorderPaint = new Paint(); mBorderPaint.setAntiAlias(true); mBorderPaint.setStyle(Paint.Style.STROKE); mBorderPaint.setStrokeWidth(dp2px(2)); //mBgPaint = new Paint(); mWavePaint = new Paint(); mWavePaint.setAntiAlias(true); mWaveShaderMatrix = new Matrix(); mTitlePaint = new Paint(); mTitlePaint.setColor(DEFAULT_TITLE_COLOR); mTitlePaint.setStyle(Paint.Style.FILL); mTitlePaint.setAntiAlias(true); mTitlePaint.setTextSize(DEFAULT_TITLE_CENTER_SIZE); initBasicTravelAnimation(); attributes.recycle(); }
Example 9
Source File: LocationBitmapFactory.java From mage-android with Apache License 2.0 | 5 votes |
private static Bitmap createDot(Context context, Location location) { int color = locationColor(context, location); Bitmap bitmap = DOTS.get(color); if (bitmap != null) { return bitmap; } float density = context.getResources().getDisplayMetrics().density; int dimension = (int) (DOT_DIMENSION * density); int radius = (int) (DOT_RADIUS * density); bitmap = Bitmap.createBitmap(dimension, dimension, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setStyle(Paint.Style.FILL); paint.setColor(color); canvas.drawCircle(dimension / 2f, dimension / 2f, radius, paint); paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(4); paint.setColor(Color.WHITE); canvas.drawCircle(dimension / 2f, dimension / 2f, radius, paint); canvas.drawBitmap(bitmap, 0, 0, paint); DOTS.put(color, bitmap); return bitmap; }
Example 10
Source File: Switch.java From meiShi with Apache License 2.0 | 5 votes |
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (!placedBall) { placeBall(); } // Crop line to transparent effect if(null == bitmap) { bitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888); } Canvas temp = new Canvas(bitmap); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor((eventCheck) ? backgroundColor : Color.parseColor("#B0B0B0")); paint.setStrokeWidth(Utils.dpToPx(2, getResources())); temp.drawLine(getHeight() / 2, getHeight() / 2, getWidth() - getHeight() / 2, getHeight() / 2, paint); Paint transparentPaint = new Paint(); transparentPaint.setAntiAlias(true); transparentPaint.setColor(getResources().getColor( android.R.color.transparent)); transparentPaint.setXfermode(new PorterDuffXfermode( PorterDuff.Mode.CLEAR)); temp.drawCircle(ViewHelper.getX(ball) + ball.getWidth() / 2, ViewHelper.getY(ball) + ball.getHeight() / 2, ball.getWidth() / 2, transparentPaint); canvas.drawBitmap(bitmap, 0, 0, new Paint()); if (press) { paint.setColor((check) ? makePressColor() : Color .parseColor("#446D6D6D")); canvas.drawCircle(ViewHelper.getX(ball) + ball.getWidth() / 2, getHeight() / 2, getHeight() / 2, paint); } invalidate(); }
Example 11
Source File: PaintUtil.java From UltimateAndroid with Apache License 2.0 | 5 votes |
/** * Creates the Paint object for drawing the corners of the border * * @param context the Context * @return the new Paint object */ public static Paint newCornerPaint(Context context) { // Set the line thickness for the crop window border. final float lineThicknessPx = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, DEFAULT_CORNER_THICKNESS_DP, context.getResources().getDisplayMetrics()); final Paint cornerPaint = new Paint(); cornerPaint.setColor(DEFAULT_CORNER_COLOR); cornerPaint.setStrokeWidth(lineThicknessPx); cornerPaint.setStyle(Paint.Style.STROKE); return cornerPaint; }
Example 12
Source File: DoubleCircleBuilder.java From AndroidWallet with GNU General Public License v3.0 | 5 votes |
/** * 初始化画笔 */ private void initPaint(float lineWidth) { mStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mStrokePaint.setStyle(Paint.Style.STROKE); mStrokePaint.setStrokeWidth(lineWidth); mStrokePaint.setColor(Color.WHITE); mStrokePaint.setDither(true); mStrokePaint.setFilterBitmap(true); mStrokePaint.setStrokeCap(Paint.Cap.ROUND); mStrokePaint.setStrokeJoin(Paint.Join.ROUND); }
Example 13
Source File: BallTrianglePathIndicator.java From LazyRecyclerAdapter with MIT License | 5 votes |
@Override public void draw(Canvas canvas, Paint paint) { paint.setStrokeWidth(3); paint.setStyle(Paint.Style.STROKE); for (int i = 0; i < 3; i++) { canvas.save(); canvas.translate(translateX[i], translateY[i]); canvas.drawCircle(0, 0, getWidth() / 10, paint); canvas.restore(); } }
Example 14
Source File: CircularSeekBar.java From Melophile with Apache License 2.0 | 4 votes |
/** * Initializes the {@code Paint} objects with the appropriate styles. */ private void initPaints() { mCirclePaint = new Paint(); mCirclePaint.setAntiAlias(true); mCirclePaint.setDither(true); mCirclePaint.setColor(mCircleColor); mCirclePaint.setStrokeWidth(mCircleStrokeWidth); mCirclePaint.setStyle(Paint.Style.STROKE); mCirclePaint.setStrokeJoin(Paint.Join.ROUND); mCirclePaint.setStrokeCap(Paint.Cap.ROUND); mCircleFillPaint = new Paint(); mCircleFillPaint.setAntiAlias(true); mCircleFillPaint.setDither(true); mCircleFillPaint.setColor(mCircleFillColor); mCircleFillPaint.setStyle(Paint.Style.FILL); mCircleProgressPaint = new Paint(); mCircleProgressPaint.setAntiAlias(true); mCircleProgressPaint.setDither(true); mCircleProgressPaint.setColor(mCircleProgressColor); mCircleProgressPaint.setStrokeWidth(mCircleStrokeWidth); mCircleProgressPaint.setStyle(Paint.Style.STROKE); mCircleProgressPaint.setStrokeJoin(Paint.Join.ROUND); mCircleProgressPaint.setStrokeCap(Paint.Cap.ROUND); mCircleProgressGlowPaint = new Paint(); mCircleProgressGlowPaint.set(mCircleProgressPaint); mCircleProgressGlowPaint.setMaskFilter(new BlurMaskFilter((5f * DPTOPX_SCALE), BlurMaskFilter.Blur.NORMAL)); mPointerPaint = new Paint(); mPointerPaint.setAntiAlias(true); mPointerPaint.setDither(true); mPointerPaint.setStyle(Paint.Style.FILL); mPointerPaint.setColor(mPointerColor); mPointerPaint.setStrokeWidth(mPointerRadius); mPointerHaloPaint = new Paint(); mPointerHaloPaint.set(mPointerPaint); mPointerHaloPaint.setColor(mPointerHaloColor); mPointerHaloPaint.setAlpha(mPointerAlpha); mPointerHaloPaint.setStrokeWidth(mPointerRadius + mPointerHaloWidth); mPointerHaloBorderPaint = new Paint(); mPointerHaloBorderPaint.set(mPointerPaint); mPointerHaloBorderPaint.setStrokeWidth(mPointerHaloBorderWidth); mPointerHaloBorderPaint.setStyle(Paint.Style.STROKE); }
Example 15
Source File: BarGraphView.java From HzGrapher with Apache License 2.0 | 4 votes |
private void drawGraphWithoutAnimation(GraphCanvasWrapper canvas){ Log.d(TAG, "drawGraphWithoutAnimation"); Paint barGraphRegionPaint = new Paint(); barGraphRegionPaint.setFlags(Paint.ANTI_ALIAS_FLAG); barGraphRegionPaint.setAntiAlias(true); //text anti alias barGraphRegionPaint.setFilterBitmap(true); // bitmap anti alias barGraphRegionPaint.setStrokeWidth(0); Paint barPercentPaint = new Paint(); barPercentPaint.setFlags(Paint.ANTI_ALIAS_FLAG); barPercentPaint.setAntiAlias(true); barPercentPaint.setColor(Color.WHITE); barPercentPaint.setTextSize(20); float yBottom = 0; float yBottomOld = 0; //x축 반복 for(int i=0; i< mBarGraphVO.getLegendArr().length; i++){ float xLeft = xLength * mBarGraphVO.getIncrementX() * (i+1)/mBarGraphVO.getMaxValueX() - mBarGraphVO.getBarWidth() / 2; float xRight = xLeft + mBarGraphVO.getBarWidth(); float totalYLength = 0; for (int j = 0; j < mBarGraphVO.getArrGraph().size(); j++) { totalYLength += yLength * mBarGraphVO.getArrGraph().get(j).getCoordinateArr()[i]/mBarGraphVO.getMaxValueY(); } //x축 각 섹션별 반복 for (int j = 0; j < mBarGraphVO.getArrGraph().size(); j++) { BarGraph graph = mBarGraphVO.getArrGraph().get(j); yBottomOld = yBottom; yBottom += yLength * graph.getCoordinateArr()[i]/mBarGraphVO.getMaxValueY(); barGraphRegionPaint.setColor(mBarGraphVO.getArrGraph().get(j).getColor()); canvas.drawRect(xLeft, yBottomOld, xRight, yBottom, barGraphRegionPaint); int percentage = (int) (((yBottom - yBottomOld)*100)/totalYLength); if(percentage != 0){ String mark = String.valueOf(percentage)+"%"; barPercentPaint.measureText(mark); Rect rect = new Rect(); barPercentPaint.getTextBounds(mark, 0, mark.length(), rect); canvas.drawText(mark, xRight-((xRight-xLeft)/2)-rect.width()/2, yBottom-((yBottom-yBottomOld)/2)-rect.height()/2, barPercentPaint); } } yBottom = 0; } }
Example 16
Source File: SmoothProgressDrawable.java From UltimateAndroid with Apache License 2.0 | 4 votes |
private SmoothProgressDrawable(Interpolator interpolator, int sectionsCount, int separatorLength, int[] colors, float strokeWidth, float speed, float progressiveStartSpeed, float progressiveStopSpeed, boolean reversed, boolean mirrorMode, Callbacks callbacks, boolean progressiveStartActivated, Drawable backgroundDrawable) { mRunning = false; mInterpolator = interpolator; mSectionsCount = sectionsCount; mStartSection = 0; mCurrentSections = mSectionsCount; mSeparatorLength = separatorLength; mSpeed = speed; mProgressiveStartSpeed = progressiveStartSpeed; mProgressiveStopSpeed = progressiveStopSpeed; mReversed = reversed; mColors = colors; mColorsIndex = 0; mMirrorMode = mirrorMode; mFinishing = false; mBackgroundDrawable = backgroundDrawable; mStrokeWidth = strokeWidth; mMaxOffset = 1f / mSectionsCount; mPaint = new Paint(); mPaint.setStrokeWidth(strokeWidth); mPaint.setStyle(Paint.Style.STROKE); mPaint.setDither(false); mPaint.setAntiAlias(false); mProgressiveStartActivated = progressiveStartActivated; mCallbacks = callbacks; }
Example 17
Source File: BarGraphView.java From HzGrapher with Apache License 2.0 | 4 votes |
private void drawGraphWithAnimation(GraphCanvasWrapper canvas){ Log.d(TAG, "drawGraphWithAnimation"); Paint barGraphRegionPaint = new Paint(); barGraphRegionPaint.setFlags(Paint.ANTI_ALIAS_FLAG); barGraphRegionPaint.setAntiAlias(true); //text anti alias barGraphRegionPaint.setFilterBitmap(true); // bitmap anti alias barGraphRegionPaint.setStrokeWidth(0); // Paint barPercentPaint = new Paint(); // barPercentPaint.setFlags(Paint.ANTI_ALIAS_FLAG); // barPercentPaint.setAntiAlias(true); // barPercentPaint.setColor(Color.WHITE); // barPercentPaint.setTextSize(20); long curTime = System.currentTimeMillis(); long gapTime = curTime - animStartTime; long totalAnimDuration = mBarGraphVO.getAnimation().getDuration(); if(gapTime >= totalAnimDuration){ gapTime = totalAnimDuration; isDirty = false; } float yBottomOld = 0; //x축 반복 for(int i=0; i< mBarGraphVO.getLegendArr().length; i++){ float xLeft = xLength * mBarGraphVO.getIncrementX() * (i+1)/mBarGraphVO.getMaxValueX() - mBarGraphVO.getBarWidth() / 2; float xRight = xLeft + mBarGraphVO.getBarWidth(); float totalYLength = 0; for (int j = 0; j < mBarGraphVO.getArrGraph().size(); j++) { totalYLength += yLength * mBarGraphVO.getArrGraph().get(j).getCoordinateArr()[i]/mBarGraphVO.getMaxValueY(); } float yGap = (totalYLength / totalAnimDuration) * gapTime; Log.d(TAG, "yGap = "+yGap); barGraphRegionPaint.setColor(mBarGraphVO.getArrGraph().get(0).getColor()); canvas.drawRect(xLeft, yBottomOld, xRight, yGap, barGraphRegionPaint); } }
Example 18
Source File: PagerSlidingTabStrip.java From light-novel-library_Wenku8_Android with GNU General Public License v2.0 | 4 votes |
public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setFillViewport(true); 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_DIP, 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); tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm); // get system attrs (android:textSize and android:textColor) TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); tabTextSize = a.getDimensionPixelSize(TEXT_SIZE_INDEX, tabTextSize); ColorStateList colorStateList = a.getColorStateList(TEXT_COLOR_INDEX); int textPrimaryColor = a.getColor(TEXT_COLOR_PRIMARY, getResources().getColor(android.R.color.white)); if (colorStateList != null) { tabTextColor = colorStateList; } else { tabTextColor = getColorStateList(textPrimaryColor); } underlineColor = textPrimaryColor; dividerColor = textPrimaryColor; indicatorColor = textPrimaryColor; int paddingLeft = a.getDimensionPixelSize(PADDING_LEFT_INDEX, padding); int paddingRight = a.getDimensionPixelSize(PADDING_RIGHT_INDEX, padding); a.recycle(); //In case we have the padding they must be equal so we take the biggest padding = Math.max(paddingLeft, paddingRight); // 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); dividerWidth = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerWidth, dividerWidth); 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); tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground, tabBackgroundResId); shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand); scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset); textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps); isPaddingMiddle = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsPaddingMiddle, isPaddingMiddle); tabTypefaceStyle = a.getInt(R.styleable.PagerSlidingTabStrip_pstsTextStyle, Typeface.BOLD); tabTypefaceSelectedStyle = a.getInt(R.styleable.PagerSlidingTabStrip_pstsTextSelectedStyle, Typeface.BOLD); tabTextAlpha = a.getFloat(R.styleable.PagerSlidingTabStrip_pstsTextAlpha, HALF_TRANSP); tabTextSelectedAlpha = a.getFloat(R.styleable.PagerSlidingTabStrip_pstsTextSelectedAlpha, OPAQUE); a.recycle(); setMarginBottomTabContainer(); rectPaint = new Paint(); rectPaint.setAntiAlias(true); rectPaint.setStyle(Style.FILL); dividerPaint = new Paint(); dividerPaint.setAntiAlias(true); dividerPaint.setStrokeWidth(dividerWidth); defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f); if (locale == null) { locale = getResources().getConfiguration().locale; } }
Example 19
Source File: CircleShapeRenderer.java From JNChartDemo with Apache License 2.0 | 4 votes |
@Override public void renderShape( Canvas c, IScatterDataSet dataSet, ViewPortHandler mViewPortHandler, ScatterBuffer buffer, Paint mRenderPaint, final float shapeSize) { final float shapeHalf = shapeSize / 2f; final float shapeHoleSizeHalf = Utils.convertDpToPixel(dataSet.getScatterShapeHoleRadius()); final float shapeHoleSize = shapeHoleSizeHalf * 2.f; final float shapeStrokeSize = (shapeSize - shapeHoleSize) / 2.f; final float shapeStrokeSizeHalf = shapeStrokeSize / 2.f; final int shapeHoleColor = dataSet.getScatterShapeHoleColor(); for (int i = 0; i < buffer.size(); i += 2) { if (!mViewPortHandler.isInBoundsRight(buffer.buffer[i])) break; if (!mViewPortHandler.isInBoundsLeft(buffer.buffer[i]) || !mViewPortHandler.isInBoundsY(buffer.buffer[i + 1])) continue; mRenderPaint.setColor(dataSet.getColor(i / 2)); if (shapeSize > 0.0) { mRenderPaint.setStyle(Paint.Style.STROKE); mRenderPaint.setStrokeWidth(shapeStrokeSize); c.drawCircle( buffer.buffer[i], buffer.buffer[i + 1], shapeHoleSizeHalf + shapeStrokeSizeHalf, mRenderPaint); if (shapeHoleColor != ColorTemplate.COLOR_NONE) { mRenderPaint.setStyle(Paint.Style.FILL); mRenderPaint.setColor(shapeHoleColor); c.drawCircle( buffer.buffer[i], buffer.buffer[i + 1], shapeHoleSizeHalf, mRenderPaint); } } else { mRenderPaint.setStyle(Paint.Style.FILL); c.drawCircle( buffer.buffer[i], buffer.buffer[i + 1], shapeHalf, mRenderPaint); } } }
Example 20
Source File: MagicProgressCircle.java From MagicProgressWidget with Apache License 2.0 | 4 votes |
private void init(final Context context, final AttributeSet attrs) { float defaultPercent = -1; if (isInEditMode()) { defaultPercent = 0.6f; } do { final int strokeWdithDefaultValue = (int) (18 * getResources().getDisplayMetrics().density + 0.5f); if (context == null || attrs == null) { strokeWidth = strokeWdithDefaultValue; percent = defaultPercent; startColor = getResources().getColor(R.color.mpc_start_color); endColor = getResources().getColor(R.color.mpc_end_color); defaultColor = getResources().getColor(R.color.mpc_default_color); break; } TypedArray typedArray = null; try { typedArray = context.obtainStyledAttributes(attrs, R.styleable.MagicProgressCircle); percent = typedArray.getFloat(R.styleable.MagicProgressCircle_mpc_percent, defaultPercent); strokeWidth = (int) typedArray.getDimension(R.styleable.MagicProgressCircle_mpc_stroke_width, strokeWdithDefaultValue); startColor = typedArray.getColor(R.styleable.MagicProgressCircle_mpc_start_color, getResources().getColor(R.color.mpc_start_color)); endColor = typedArray.getColor(R.styleable.MagicProgressCircle_mpc_end_color, getResources().getColor(R.color.mpc_end_color)); defaultColor = typedArray.getColor(R.styleable.MagicProgressCircle_mpc_default_color, getResources().getColor(R.color.mpc_default_color)); isFootOverHead = typedArray.getBoolean(R.styleable.MagicProgressCircle_mpc_foot_over_head, false); } finally { if (typedArray != null) { typedArray.recycle(); } } } while (false); paint = new Paint(); paint.setAntiAlias(true); paint.setStrokeWidth(strokeWidth); paint.setStyle(Paint.Style.STROKE); paint.setStrokeJoin(Paint.Join.ROUND); paint.setStrokeCap(Paint.Cap.ROUND); startPaint = new Paint(); startPaint.setColor(startColor); startPaint.setAntiAlias(true); startPaint.setStyle(Paint.Style.FILL); endPaint = new Paint(); endPaint.setAntiAlias(true); endPaint.setStyle(Paint.Style.FILL); refreshDelta(); customColors = new int[]{startColor, percentEndColor, defaultColor, defaultColor}; fullColors = new int[]{startColor, endColor}; emptyColors = new int[]{defaultColor, defaultColor}; customPositions = new float[4]; customPositions[0] = 0; customPositions[3] = 1; extremePositions = new float[]{0, 1}; }