Java Code Examples for android.graphics.Paint#LINEAR_TEXT_FLAG
The following examples show how to use
android.graphics.Paint#LINEAR_TEXT_FLAG .
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: WheelPicker.java From DatePicker with MIT License | 6 votes |
private void initPaint() { mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG | Paint.LINEAR_TEXT_FLAG); mPaint.setStyle(Paint.Style.FILL); mPaint.setTextAlign(Paint.Align.CENTER); mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG | Paint.LINEAR_TEXT_FLAG); mTextPaint.setStyle(Paint.Style.FILL); mTextPaint.setTextAlign(Paint.Align.CENTER); mTextPaint.setColor(mTextColor); mTextPaint.setTextSize(mTextSize); mSelectedItemPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG | Paint.LINEAR_TEXT_FLAG); mSelectedItemPaint.setStyle(Paint.Style.FILL); mSelectedItemPaint.setTextAlign(Paint.Align.CENTER); mSelectedItemPaint.setColor(mSelectedItemTextColor); mSelectedItemPaint.setTextSize(mSelectedItemTextSize); mIndicatorPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG | Paint.LINEAR_TEXT_FLAG); mIndicatorPaint.setStyle(Paint.Style.FILL); mIndicatorPaint.setTextAlign(Paint.Align.LEFT); mIndicatorPaint.setColor(mIndicatorTextColor); mIndicatorPaint.setTextSize(mIndicatorTextSize); }
Example 2
Source File: MultipleProgressBar.java From RetrofitClient with MIT License | 6 votes |
private void init(Context context, AttributeSet attrs) { TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.MultipleProgressBar); type = array.getColor(R.styleable.MultipleProgressBar_type, ProgressBarType.RECT); progressColor = array.getColor(R.styleable.MultipleProgressBar_progress_color, Color.GREEN); bgColor = array.getColor(R.styleable.MultipleProgressBar_bg_color, Color.GRAY); strokeColor = array.getColor(R.styleable.MultipleProgressBar_stroke_color, Color.GRAY); mRadius = array.getDimension(R.styleable.MultipleProgressBar_radius, 10); strokeWidth = array.getDimension(R.styleable.MultipleProgressBar_stroke_width, 0); mRectTop = array.getDimension(R.styleable.MultipleProgressBar_rect_top, 0); mTextSize = array.getDimension(R.styleable.MultipleProgressBar_text_size, 24); array.recycle(); mProgressPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG | Paint.LINEAR_TEXT_FLAG); mProgressPaint.setColor(progressColor); mProgressPaint.setStyle(Paint.Style.FILL); mProgressPaint.setTextSize(mTextSize); mBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG | Paint.LINEAR_TEXT_FLAG); mBgPaint.setColor(bgColor); mBgPaint.setStyle(Paint.Style.FILL); mStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG | Paint.LINEAR_TEXT_FLAG); mStrokePaint.setColor(strokeColor); mStrokePaint.setStyle(Paint.Style.STROKE); }
Example 3
Source File: NiceProgressBar.java From NiceProgressBar with Apache License 2.0 | 5 votes |
private void init() { mColorWheelRectangle = new RectF(); circleStrokeWidth = DensityUtil.dip2px(getContext(), 10); mTextSize = DensityUtil.dip2px(getContext(), 40); mColorWheelPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mColorWheelPaint.setColor(mWheelColor); mColorWheelPaint.setStyle(Paint.Style.STROKE); mColorWheelPaint.setStrokeWidth(circleStrokeWidth); mDefaultWheelPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mDefaultWheelPaint.setColor(mWheelColorDefault); mDefaultWheelPaint.setStyle(Paint.Style.STROKE); mDefaultWheelPaint.setStrokeWidth(circleStrokeWidth); textPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG); textPaint.setColor(textColor); textPaint.setStyle(Style.FILL_AND_STROKE); textPaint.setTextAlign(Align.LEFT); textPaint.setTextSize(mTextSize); mText = 0; mSweepAngle = 0; anim = new myProgressBarAnimation(); anim.setDuration(mAnimDuration); }
Example 4
Source File: PitchSensorAnimationBehavior.java From science-journal with Apache License 2.0 | 5 votes |
PitchSensorAnimationBehavior() { paintForDot = new Paint(); paintForDot.setColor(Color.RED); paintForShade = new Paint(); paintForShade.setColor(makeShadeColor(0)); Typeface sansSerifBold = Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD); paintForNoteLeft = new Paint(Paint.LINEAR_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG); paintForNoteLeft.setTextAlign(Paint.Align.CENTER); paintForNoteLeft.setColor(COLOR_NOTE_LEFT); paintForNoteLeft.setTypeface(sansSerifBold); paintForNoteRight = new Paint(Paint.LINEAR_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG); paintForNoteRight.setTextAlign(Paint.Align.CENTER); paintForNoteRight.setColor(COLOR_NOTE_RIGHT); paintForNoteRight.setTypeface(sansSerifBold); paintForSign = new Paint(Paint.LINEAR_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG); paintForSign.setTextAlign(Paint.Align.CENTER); paintForSign.setColor(COLOR_SIGN); paintForSign.setTypeface(sansSerifBold); paintForOctave = new Paint(Paint.LINEAR_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG); paintForOctave.setTextAlign(Paint.Align.CENTER); paintForOctave.setColor(COLOR_OCTAVE); paintForOctave.setTypeface(sansSerifBold); }
Example 5
Source File: MCTileProvider.java From blocktopograph with GNU Affero General Public License v3.0 | 5 votes |
public static Bitmap drawText(String text, Bitmap b, int textColor, int bgColor) { // Get text dimensions TextPaint textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG); textPaint.setStyle(Paint.Style.FILL); textPaint.setColor(textColor); textPaint.setTextSize(b.getHeight() / 16f); StaticLayout mTextLayout = new StaticLayout(text, textPaint, b.getWidth() / 2, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); // Create bitmap and canvas to draw to Canvas c = new Canvas(b); if(bgColor != 0){ // Draw background Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG); paint.setStyle(Paint.Style.FILL); paint.setColor(bgColor); c.drawPaint(paint); } // Draw text c.save(); c.translate(0, 0); mTextLayout.draw(c); c.restore(); return b; }
Example 6
Source File: MonthView.java From Android-LunarView with Apache License 2.0 | 5 votes |
private void init() { paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG | Paint.LINEAR_TEXT_FLAG); paint.setTextAlign(Paint.Align.CENTER); if (month.isMonthOfToday()) { selectedIndex = month.getIndexOfToday(); } setBackgroundColor(lunarView.getMonthBackgroundColor()); }
Example 7
Source File: WeekLabelView.java From Android-LunarView with Apache License 2.0 | 5 votes |
private void init() { paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG | Paint.LINEAR_TEXT_FLAG); paint.setTextAlign(Paint.Align.CENTER); paint.setColor(Color.GRAY); int padding = dip2px(getContext()); setPadding(0, padding, 0, padding); for (int i = 0; i < DAYS_IN_WEEK; i++) { Region region = new Region(); weekRegion[i] = region; } }
Example 8
Source File: AzkarActivity.java From MuslimMateAndroid with GNU General Public License v3.0 | 4 votes |
/** * Share Button Click. * get hadith text and create bitmap with hadith text and share it. */ private void onShareButtonClicked(String subject, String body) { // check if app grant write external storage permission. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // check permission for marshmellow. if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { // Camera permission has not been granted. // Camera permission has not been granted yet. Request it directly. requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1); return; } } // create image from hadith and try share it Resources resources = getResources(); // Create background bitmap Bitmap backgroundBitmap = BitmapFactory.decodeResource(resources, R.drawable.backgroundtile); Bitmap.Config config = backgroundBitmap.getConfig(); if (config == null) { config = Bitmap.Config.ARGB_8888; } int width = 600 + (body.length() / 512) * 50;//backgroundBitmap.getWidth(); // Create logo bitmap Bitmap logoBitmap = BitmapFactory.decodeResource(resources, R.mipmap.ic_launcher); logoBitmap = Bitmap.createScaledBitmap(logoBitmap, 128, 128, false); logoBitmap = logoBitmap.copy(config, false); int padding = 15; // Initiate text paint objects TextPaint titleTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG); titleTextPaint.setStyle(Paint.Style.FILL); titleTextPaint.setTextSize(28); titleTextPaint.setColor(Color.rgb(64, 0, 0)); titleTextPaint.setTypeface(Typeface.createFromAsset(getActivity().getAssets(), "fonts/simple.otf")); StaticLayout titleStaticLayout = new StaticLayout("منظم المسلم" + "\n" + subject, titleTextPaint, width - 3 * padding - logoBitmap.getWidth(), Layout.Alignment.ALIGN_NORMAL, 1.4f, 0.1f, false); TextPaint matnTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG); matnTextPaint.setStyle(Paint.Style.FILL); matnTextPaint.setTextSize(30); matnTextPaint.setColor(Color.BLACK); matnTextPaint.setTypeface(Typeface.createFromAsset(getActivity().getAssets(), "fonts/simple.otf")); StaticLayout matnStaticLayout = new StaticLayout(body + "\n", matnTextPaint, width - 2 * padding, Layout.Alignment.ALIGN_CENTER, 1.4f, 0.1f, false); int height = padding + Math.max(titleStaticLayout.getHeight(), logoBitmap.getHeight()) + padding + matnStaticLayout.getHeight() + padding; Bitmap bitmap = backgroundBitmap.copy(config, true); bitmap = Bitmap.createScaledBitmap(bitmap, width, height, false); // create canvas and draw text on image. Canvas canvas = new Canvas(bitmap); canvas.save(); tileBitmap(canvas, backgroundBitmap); canvas.drawBitmap(logoBitmap, width - padding - logoBitmap.getWidth(), padding, null); canvas.translate(padding, 2 * padding); titleStaticLayout.draw(canvas); canvas.translate(0, padding + logoBitmap.getHeight()); matnStaticLayout.draw(canvas); canvas.restore(); // share bitmap. shareImage(bitmap); }
Example 9
Source File: WheelPicker.java From ScrollChoice with MIT License | 4 votes |
public WheelPicker(Context context, AttributeSet attrs) { super(context, attrs); adapter = new Adapter(); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.WheelPicker); mItemTextSize = a.getDimensionPixelSize(R.styleable.WheelPicker_scroll_item_text_size, getResources().getDimensionPixelSize(R.dimen.WheelItemTextSize)); mVisibleItemCount = a.getInt(R.styleable.WheelPicker_scroll_visible_item_count, 7); selectedItemPosition = a.getInt(R.styleable.WheelPicker_scroll_selected_item_position, 0); textMaxWidthPosition = a.getInt(R.styleable.WheelPicker_scroll_maximum_width_text_position, -1); maxWidthText = a.getString(R.styleable.WheelPicker_scroll_maximum_width_text); mSelectedItemTextColor = a.getColor(R.styleable.WheelPicker_scroll_selected_item_text_color, -1); mItemTextColor = a.getColor(R.styleable.WheelPicker_scroll_item_text_color, 0xFF424242); backgroundColor = a.getColor(R.styleable.WheelPicker_scroll_background_color, 0xFFF5F5F5); backgroundOfSelectedItem = a.getColor(R.styleable.WheelPicker_scroll_selected_item_background, 0xFFFFFFFF); mItemSpace = a.getDimensionPixelSize(R.styleable.WheelPicker_scroll_item_space, getResources().getDimensionPixelSize(R.dimen.WheelItemSpace)); hasIndicator = a.getBoolean(R.styleable.WheelPicker_scroll_indicator, false); mIndicatorColor = a.getColor(R.styleable.WheelPicker_scroll_indicator_color, 0xFFDDDDDD); mIndicatorSize = a.getDimensionPixelSize(R.styleable.WheelPicker_scroll_indicator_size, getResources().getDimensionPixelSize(R.dimen.WheelIndicatorSize)); hasAtmospheric = a.getBoolean(R.styleable.WheelPicker_scroll_atmospheric, false); mItemAlign = a.getInt(R.styleable.WheelPicker_scroll_item_align, ALIGN_CENTER); a.recycle(); updateVisibleItemCount(); paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG | Paint.LINEAR_TEXT_FLAG); paintBackground = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG ); paint.setTextSize(mItemTextSize); updateItemTextAlign(); computeTextSize(); scroller = new Scroller(getContext()); ViewConfiguration conf = ViewConfiguration.get(getContext()); minimumVelocity = conf.getScaledMinimumFlingVelocity(); maximumVelocity = conf.getScaledMaximumFlingVelocity(); touchSlop = conf.getScaledTouchSlop(); rectDrawn = new Rect(); rectIndicatorHead = new Rect(); rectIndicatorFoot = new Rect(); rectCurrentItem = new Rect(); }
Example 10
Source File: WheelPicker.java From SingleDateAndTimePicker with Apache License 2.0 | 4 votes |
public WheelPicker(Context context, AttributeSet attrs) { super(context, attrs); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.WheelPicker); mItemTextSize = a.getDimensionPixelSize(R.styleable.WheelPicker_wheel_item_text_size, getResources().getDimensionPixelSize(R.dimen.WheelItemTextSize)); mVisibleItemCount = a.getInt(R.styleable.WheelPicker_wheel_visible_item_count, 7); selectedItemPosition = a.getInt(R.styleable.WheelPicker_wheel_selected_item_position, 0); hasSameWidth = a.getBoolean(R.styleable.WheelPicker_wheel_same_width, false); textMaxWidthPosition = a.getInt(R.styleable.WheelPicker_wheel_maximum_width_text_position, -1); maxWidthText = a.getString(R.styleable.WheelPicker_wheel_maximum_width_text); mSelectedItemTextColor = a.getColor(R.styleable.WheelPicker_wheel_selected_item_text_color, -1); mItemTextColor = a.getColor(R.styleable.WheelPicker_wheel_item_text_color, 0xFF888888); mItemSpace = a.getDimensionPixelSize(R.styleable.WheelPicker_wheel_item_space, getResources().getDimensionPixelSize(R.dimen.WheelItemSpace)); isCyclic = a.getBoolean(R.styleable.WheelPicker_wheel_cyclic, false); hasIndicator = a.getBoolean(R.styleable.WheelPicker_wheel_indicator, false); mIndicatorColor = a.getColor(R.styleable.WheelPicker_wheel_indicator_color, 0xFFEE3333); mIndicatorSize = a.getDimensionPixelSize(R.styleable.WheelPicker_wheel_indicator_size, getResources().getDimensionPixelSize(R.dimen.WheelIndicatorSize)); hasCurtain = a.getBoolean(R.styleable.WheelPicker_wheel_curtain, false); mCurtainColor = a.getColor(R.styleable.WheelPicker_wheel_curtain_color, 0x88FFFFFF); hasAtmospheric = a.getBoolean(R.styleable.WheelPicker_wheel_atmospheric, false); isCurved = a.getBoolean(R.styleable.WheelPicker_wheel_curved, false); mItemAlign = a.getInt(R.styleable.WheelPicker_wheel_item_align, ALIGN_CENTER); a.recycle(); updateVisibleItemCount(); paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG | Paint.LINEAR_TEXT_FLAG); paint.setTextSize(mItemTextSize); scroller = new Scroller(getContext()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.DONUT) { ViewConfiguration conf = ViewConfiguration.get(getContext()); minimumVelocity = conf.getScaledMinimumFlingVelocity(); maximumVelocity = conf.getScaledMaximumFlingVelocity(); touchSlop = conf.getScaledTouchSlop(); } init(); defaultValue = initDefault(); adapter.setData(generateAdapterValues(showOnlyFutureDate)); currentItemPosition = adapter.getItemPosition(defaultValue); selectedItemPosition = currentItemPosition; }
Example 11
Source File: WheelPicker.java From WheelPicker with Apache License 2.0 | 4 votes |
public WheelPicker(Context context, AttributeSet attrs) { super(context, attrs); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.WheelPicker); int idData = a.getResourceId(R.styleable.WheelPicker_wheel_data, 0); mData = Arrays.asList(getResources() .getStringArray(idData == 0 ? R.array.WheelArrayDefault : idData)); mItemTextSize = a.getDimensionPixelSize(R.styleable.WheelPicker_wheel_item_text_size, getResources().getDimensionPixelSize(R.dimen.WheelItemTextSize)); mVisibleItemCount = a.getInt(R.styleable.WheelPicker_wheel_visible_item_count, 7); mSelectedItemPosition = a.getInt(R.styleable.WheelPicker_wheel_selected_item_position, 0); hasSameWidth = a.getBoolean(R.styleable.WheelPicker_wheel_same_width, false); mTextMaxWidthPosition = a.getInt(R.styleable.WheelPicker_wheel_maximum_width_text_position, -1); mMaxWidthText = a.getString(R.styleable.WheelPicker_wheel_maximum_width_text); mSelectedItemTextColor = a.getColor (R.styleable.WheelPicker_wheel_selected_item_text_color, -1); mItemTextColor = a.getColor(R.styleable.WheelPicker_wheel_item_text_color, 0xFF888888); mItemSpace = a.getDimensionPixelSize(R.styleable.WheelPicker_wheel_item_space, getResources().getDimensionPixelSize(R.dimen.WheelItemSpace)); isCyclic = a.getBoolean(R.styleable.WheelPicker_wheel_cyclic, false); hasIndicator = a.getBoolean(R.styleable.WheelPicker_wheel_indicator, false); mIndicatorColor = a.getColor(R.styleable.WheelPicker_wheel_indicator_color, 0xFFEE3333); mIndicatorSize = a.getDimensionPixelSize(R.styleable.WheelPicker_wheel_indicator_size, getResources().getDimensionPixelSize(R.dimen.WheelIndicatorSize)); hasCurtain = a.getBoolean(R.styleable.WheelPicker_wheel_curtain, false); mCurtainColor = a.getColor(R.styleable.WheelPicker_wheel_curtain_color, 0x88FFFFFF); hasAtmospheric = a.getBoolean(R.styleable.WheelPicker_wheel_atmospheric, false); isCurved = a.getBoolean(R.styleable.WheelPicker_wheel_curved, false); mItemAlign = a.getInt(R.styleable.WheelPicker_wheel_item_align, ALIGN_CENTER); fontPath = a.getString(R.styleable.WheelPicker_wheel_font_path); a.recycle(); // 可见数据项改变后更新与之相关的参数 // Update relevant parameters when the count of visible item changed updateVisibleItemCount(); mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG | Paint.LINEAR_TEXT_FLAG); mPaint.setTextSize(mItemTextSize); if (fontPath != null) { Typeface typeface = Typeface.createFromAsset(context.getAssets(), fontPath); setTypeface(typeface); } // 更新文本对齐方式 // Update alignment of text updateItemTextAlign(); // 计算文本尺寸 // Correct sizes of text computeTextSize(); mScroller = new Scroller(getContext()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.DONUT) { ViewConfiguration conf = ViewConfiguration.get(getContext()); mMinimumVelocity = conf.getScaledMinimumFlingVelocity(); mMaximumVelocity = conf.getScaledMaximumFlingVelocity(); mTouchSlop = conf.getScaledTouchSlop(); } mRectDrawn = new Rect(); mRectIndicatorHead = new Rect(); mRectIndicatorFoot = new Rect(); mRectCurrentItem = new Rect(); mCamera = new Camera(); mMatrixRotate = new Matrix(); mMatrixDepth = new Matrix(); }
Example 12
Source File: PicturePasswordView.java From android-picturepassword with MIT License | 4 votes |
public PicturePasswordView( Context context, AttributeSet attrs ) { super( context, attrs ); setScaleType( ScaleType.CENTER_CROP ); mRandom = new Random(); mSeed = mRandom.nextInt(); mGridSize = DEFAULT_GRID_SIZE; /////////////////////// // Initialize Paints // /////////////////////// final DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); final float shadowOff = TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 2, displayMetrics ); mPaint = new Paint( Paint.LINEAR_TEXT_FLAG ); mPaint.setColor( Color.WHITE ); mPaint.setShadowLayer( 10, shadowOff, shadowOff, Color.BLACK ); mPaint.setTextSize( TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, FONT_SIZE, displayMetrics ) ); mPaint.setAntiAlias( true ); mCirclePaint = new Paint( Paint.ANTI_ALIAS_FLAG ); mCirclePaint.setColor( Color.argb( 255, 0x33, 0xb5, 0xe5 ) ); mCirclePaint.setStyle( Paint.Style.STROKE ); mCirclePaint.setStrokeWidth( 5 ); mUnlockPaint = new Paint( Paint.ANTI_ALIAS_FLAG ); mTextBounds = new Rect(); mPaint.getTextBounds( "8", 0, 1, mTextBounds ); /////////////////////////// // Initialize animations // /////////////////////////// mScale = 1.0f; mAnimator = new ObjectAnimator(); mAnimator.setTarget( this ); mAnimator.setFloatValues( 0, 1 ); mAnimator.setPropertyName( "scale" ); mAnimator.setDuration( 200 ); mCircleAnimator = new ObjectAnimator(); mCircleAnimator.setTarget( this ); mCircleAnimator.setPropertyName( "internalUnlockProgress" ); // ugh! mCircleAnimator.setDuration( 300 ); /////////////////////// // Hide/show numbers // /////////////////////// mShowNumbers = true; TypedArray a = context.getTheme().obtainStyledAttributes( attrs, R.styleable.PicturePasswordView, 0, 0 ); try { mShowNumbers = a.getBoolean( R.styleable.PicturePasswordView_showNumbers, true ); } finally { a.recycle(); } ////////////////////// // Initialize sizes // ////////////////////// mCircleSize = ( int ) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 6, displayMetrics ); mCircleSpacing = ( int ) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 5, displayMetrics ); mCirclePadding = ( int ) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 10, displayMetrics ); }
Example 13
Source File: WeekView.java From UltimateAndroid with Apache License 2.0 | 4 votes |
private void init() { // Get the date today. mToday = Calendar.getInstance(); mToday.set(Calendar.HOUR_OF_DAY, 0); mToday.set(Calendar.MINUTE, 0); mToday.set(Calendar.SECOND, 0); // Scrolling initialization. mGestureDetector = new GestureDetectorCompat(mContext, mGestureListener); mScroller = new OverScroller(mContext); mStickyScroller = new Scroller(mContext); // Measure settings for time column. mTimeTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mTimeTextPaint.setTextAlign(Paint.Align.RIGHT); mTimeTextPaint.setTextSize(mTextSize); mTimeTextPaint.setColor(mHeaderColumnTextColor); Rect rect = new Rect(); mTimeTextPaint.getTextBounds("00 PM", 0, "00 PM".length(), rect); mTimeTextWidth = mTimeTextPaint.measureText("00 PM"); mTimeTextHeight = rect.height(); mHeaderMarginBottom = mTimeTextHeight / 2; // Measure settings for header row. mHeaderTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mHeaderTextPaint.setColor(mHeaderColumnTextColor); mHeaderTextPaint.setTextAlign(Paint.Align.CENTER); mHeaderTextPaint.setTextSize(mTextSize); mHeaderTextPaint.getTextBounds("00 PM", 0, "00 PM".length(), rect); mHeaderTextHeight = rect.height(); mHeaderTextPaint.setTypeface(Typeface.DEFAULT_BOLD); // Prepare header background paint. mHeaderBackgroundPaint = new Paint(); mHeaderBackgroundPaint.setColor(mHeaderRowBackgroundColor); // Prepare day background color paint. mDayBackgroundPaint = new Paint(); mDayBackgroundPaint.setColor(mDayBackgroundColor); // Prepare hour separator color paint. mHourSeparatorPaint = new Paint(); mHourSeparatorPaint.setStyle(Paint.Style.STROKE); mHourSeparatorPaint.setStrokeWidth(mHourSeparatorHeight); mHourSeparatorPaint.setColor(mHourSeparatorColor); // Prepare today background color paint. mTodayBackgroundPaint = new Paint(); mTodayBackgroundPaint.setColor(mTodayBackgroundColor); // Prepare today header text color paint. mTodayHeaderTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mTodayHeaderTextPaint.setTextAlign(Paint.Align.CENTER); mTodayHeaderTextPaint.setTextSize(mTextSize); mTodayHeaderTextPaint.setTypeface(Typeface.DEFAULT_BOLD); mTodayHeaderTextPaint.setColor(mTodayHeaderTextColor); // Prepare event background color. mEventBackgroundPaint = new Paint(); mEventBackgroundPaint.setColor(Color.rgb(174, 208, 238)); // Prepare header column background color. mHeaderColumnBackgroundPaint = new Paint(); mHeaderColumnBackgroundPaint.setColor(mHeaderColumnBackgroundColor); // Prepare event text size and color. mEventTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG); mEventTextPaint.setStyle(Paint.Style.FILL); mEventTextPaint.setColor(mEventTextColor); mEventTextPaint.setTextSize(mEventTextSize); mStartDate = (Calendar) mToday.clone(); // Set default event color. mDefaultEventColor = Color.parseColor("#9fc6e7"); }
Example 14
Source File: WeekView.java From UltimateAndroid with Apache License 2.0 | 4 votes |
private void init() { // Get the date today. mToday = Calendar.getInstance(); mToday.set(Calendar.HOUR_OF_DAY, 0); mToday.set(Calendar.MINUTE, 0); mToday.set(Calendar.SECOND, 0); // Scrolling initialization. mGestureDetector = new GestureDetectorCompat(mContext, mGestureListener); mScroller = new OverScroller(mContext); mStickyScroller = new Scroller(mContext); // Measure settings for time column. mTimeTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mTimeTextPaint.setTextAlign(Paint.Align.RIGHT); mTimeTextPaint.setTextSize(mTextSize); mTimeTextPaint.setColor(mHeaderColumnTextColor); Rect rect = new Rect(); mTimeTextPaint.getTextBounds("00 PM", 0, "00 PM".length(), rect); mTimeTextWidth = mTimeTextPaint.measureText("00 PM"); mTimeTextHeight = rect.height(); mHeaderMarginBottom = mTimeTextHeight / 2; // Measure settings for header row. mHeaderTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mHeaderTextPaint.setColor(mHeaderColumnTextColor); mHeaderTextPaint.setTextAlign(Paint.Align.CENTER); mHeaderTextPaint.setTextSize(mTextSize); mHeaderTextPaint.getTextBounds("00 PM", 0, "00 PM".length(), rect); mHeaderTextHeight = rect.height(); mHeaderTextPaint.setTypeface(Typeface.DEFAULT_BOLD); // Prepare header background paint. mHeaderBackgroundPaint = new Paint(); mHeaderBackgroundPaint.setColor(mHeaderRowBackgroundColor); // Prepare day background color paint. mDayBackgroundPaint = new Paint(); mDayBackgroundPaint.setColor(mDayBackgroundColor); // Prepare hour separator color paint. mHourSeparatorPaint = new Paint(); mHourSeparatorPaint.setStyle(Paint.Style.STROKE); mHourSeparatorPaint.setStrokeWidth(mHourSeparatorHeight); mHourSeparatorPaint.setColor(mHourSeparatorColor); // Prepare today background color paint. mTodayBackgroundPaint = new Paint(); mTodayBackgroundPaint.setColor(mTodayBackgroundColor); // Prepare today header text color paint. mTodayHeaderTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mTodayHeaderTextPaint.setTextAlign(Paint.Align.CENTER); mTodayHeaderTextPaint.setTextSize(mTextSize); mTodayHeaderTextPaint.setTypeface(Typeface.DEFAULT_BOLD); mTodayHeaderTextPaint.setColor(mTodayHeaderTextColor); // Prepare event background color. mEventBackgroundPaint = new Paint(); mEventBackgroundPaint.setColor(Color.rgb(174, 208, 238)); // Prepare header column background color. mHeaderColumnBackgroundPaint = new Paint(); mHeaderColumnBackgroundPaint.setColor(mHeaderColumnBackgroundColor); // Prepare event text size and color. mEventTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG); mEventTextPaint.setStyle(Paint.Style.FILL); mEventTextPaint.setColor(mEventTextColor); mEventTextPaint.setTextSize(mEventTextSize); mStartDate = (Calendar) mToday.clone(); // Set default event color. mDefaultEventColor = Color.parseColor("#9fc6e7"); }
Example 15
Source File: HoloCircleSeekBar.java From HoloCircleSeekBar with Apache License 2.0 | 4 votes |
private void init(AttributeSet attrs, int defStyle) { final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.HoloCircleSeekBar, defStyle, 0); initAttributes(a); a.recycle(); // mAngle = (float) (-Math.PI / 2); mColorWheelPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mColorWheelPaint.setShader(s); mColorWheelPaint.setColor(unactive_wheel_color); mColorWheelPaint.setStyle(Style.STROKE); mColorWheelPaint.setStrokeWidth(mColorWheelStrokeWidth); Paint mColorCenterHalo = new Paint(Paint.ANTI_ALIAS_FLAG); mColorCenterHalo.setColor(Color.CYAN); mColorCenterHalo.setAlpha(0xCC); // mColorCenterHalo.setStyle(Paint.Style.STROKE); // mColorCenterHalo.setStrokeWidth(mColorCenterHaloRectangle.width() / // 2); mPointerHaloPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPointerHaloPaint.setColor(pointer_halo_color); mPointerHaloPaint.setStrokeWidth(mPointerRadius + 10); // mPointerHaloPaint.setAlpha(150); textPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG); textPaint.setColor(text_color); textPaint.setStyle(Style.FILL_AND_STROKE); textPaint.setTextAlign(Align.LEFT); // canvas.drawPaint(textPaint); textPaint.setTextSize(text_size); mPointerColor = new Paint(Paint.ANTI_ALIAS_FLAG); mPointerColor.setStrokeWidth(mPointerRadius); // mPointerColor.setColor(calculateColor(mAngle)); mPointerColor.setColor(pointer_color); mArcColor = new Paint(Paint.ANTI_ALIAS_FLAG); mArcColor.setColor(wheel_color); mArcColor.setStyle(Style.STROKE); mArcColor.setStrokeWidth(mColorWheelStrokeWidth); Paint mCircleTextColor = new Paint(Paint.ANTI_ALIAS_FLAG); mCircleTextColor.setColor(Color.WHITE); mCircleTextColor.setStyle(Style.FILL); arc_finish_radians = (int) calculateAngleFromText(init_position) - 90; if (arc_finish_radians > end_wheel) arc_finish_radians = end_wheel; mAngle = calculateAngleFromRadians(arc_finish_radians > end_wheel ? end_wheel : arc_finish_radians); setTextFromAngle(calculateValueFromAngle(arc_finish_radians)); invalidate(); }
Example 16
Source File: MyView.java From journaldev with MIT License | 2 votes |
public MyView(Context context) { super(context); mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setStyle(Paint.Style.STROKE); mPaint.setColor(Color.BLUE); mPaint.setStrokeWidth(5); mTextPaint = new Paint(Paint.LINEAR_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG); mTextPaint.setColor(Color.BLACK); mTextPaint.setTextSize(pxFromDp(context, 24)); otherPaint = new Paint(); outerPaint = new Paint(); outerPaint.setStyle(Paint.Style.FILL); outerPaint.setColor(Color.YELLOW); mPadding = 100; DisplayMetrics displayMetrics = new DisplayMetrics(); ((Activity) getContext()).getWindowManager() .getDefaultDisplay() .getMetrics(displayMetrics); int screenWidth = displayMetrics.widthPixels; int screenHeight = displayMetrics.heightPixels; arcLeft = pxFromDp(context, 20); arcTop = pxFromDp(context, 20); arcRight = pxFromDp(context, 100); arcBottom = pxFromDp(context, 100); Point p1 = new Point((int) pxFromDp(context, 80) + (screenWidth / 2), (int) pxFromDp(context, 40)); Point p2 = new Point((int) pxFromDp(context, 40) + (screenWidth / 2), (int) pxFromDp(context, 80)); Point p3 = new Point((int) pxFromDp(context, 120) + (screenWidth / 2), (int) pxFromDp(context, 80)); mPath = new Path(); mPath.moveTo(p1.x, p1.y); mPath.lineTo(p2.x, p2.y); mPath.lineTo(p3.x, p3.y); mPath.close(); mRectF = new RectF(screenWidth / 4, screenHeight / 3, screenWidth / 6, screenHeight / 2); }