本文整理汇总了Java中android.graphics.Paint.LINEAR_TEXT_FLAG属性的典型用法代码示例。如果您正苦于以下问题:Java Paint.LINEAR_TEXT_FLAG属性的具体用法?Java Paint.LINEAR_TEXT_FLAG怎么用?Java Paint.LINEAR_TEXT_FLAG使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.graphics.Paint
的用法示例。
在下文中一共展示了Paint.LINEAR_TEXT_FLAG属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupPaint
private void setupPaint() {
progressBarPaint = new Paint();
progressBarPaint.setColor((change < 100) ? barNegativeColor : barPositiveColor);
barBorderPaint = new Paint();
barBorderPaint.setColor(barBorderColor);
barBorderPaint.setStrokeWidth(barBorderThickness);
if (shadowEnabled) {
setLayerType(LAYER_TYPE_SOFTWARE, barBorderPaint);
barBorderPaint.setShadowLayer(6, 2, 2, Color.parseColor("#424242"));
}
whitePaint = new Paint();
whitePaint.setColor(Color.WHITE);
textPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG);
textPaint.setColor(textColor);
textPaint.setTypeface(Typeface.create("sans-serif-condensed", Typeface.ITALIC));
textPaint.setTextSize(UiUtils.dpToPx(14));
textPaint.setStyle(Paint.Style.FILL);
markerLinePaint = new Paint();
markerLinePaint.setColor(markerLineColor);
markerLinePaint.setStrokeWidth(UiUtils.dpToPx(2));
Rect rect = new Rect();
textPaint.getTextBounds("23 Mar", 0, 6, rect);
estimatedTextWidth = rect.width();
estimatedTextHeight = UiUtils.dpToPx(rect.height());
extraDateHeight = estimatedTextHeight + UiUtils.dpToPx(8);
}
示例2: getInitialsBitmap
/** Constructing a bitmap with the given text written in it.*/
public static Bitmap getInitialsBitmap(int backGroundColor, int textColor, String initials){
int size = BDefines.ImageProperties.INITIALS_IMAGE_SIZE;
float textSize = BDefines.ImageProperties.INITIALS_TEXT_SIZE;
int textSpace = size/2;
// Create bitmap and canvas to draw to
Bitmap b = Bitmap.createBitmap(size, size, Bitmap.Config.RGB_565);
Canvas c= new Canvas(b);
// Draw background
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG
| Paint.LINEAR_TEXT_FLAG);
paint.setStyle(Paint.Style.FILL);
paint.setColor(backGroundColor);
c.drawPaint(paint);
// Draw text
c.save();
Bitmap textBitmap = textAsBitmap(initials, textSize, textColor);
c.drawBitmap(textAsBitmap(initials, textSize, textColor), textSpace - textBitmap.getWidth()/2, textSpace - textBitmap.getHeight()/2, null);
c.restore();
return b;
}
示例3: BubbleRank
public BubbleRank(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
imageTargets = new ArrayList<>();
bitmapList = new SparseArray<>();
smallPicShaders = new SparseArray<>();
bigPicShaders = new SparseArray<>();
currentShader = null;
offset = getResources().getDimensionPixelOffset(R.dimen.rank_default_radial_offset);
mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG);
mTextPaint.setColor(ContextCompat.getColor(getContext(), R.color.br_white));
mTextPaint.setTextAlign(Paint.Align.CENTER);
mTextPaint.setTextSize(getResources().getDimension(R.dimen.rank_default_text_size));
mCirclePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mCirclePaint.setColor(ContextCompat.getColor(getContext(), R.color.br_light_grey));
mCircleBorderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mCircleBorderPaint.setColor(ContextCompat.getColor(getContext(), R.color.br_white));
mCircleBorderPaint.setStyle(Paint.Style.STROKE);
mCircleBorderPaint.setStrokeWidth(getResources().getDimensionPixelSize(R.dimen.rank_default_border_width));
// Setting defaults, 4 circles can be overridden by API
mCircleCount = 4;
mCurrentRank = 0;
mRankList = new ArrayList<>();
mBounds = new Rect();
}
示例4: init
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);
}
示例5: onShareButtonClicked
/**
* 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);
}
示例6: WheelPicker
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();
}
示例7: WheelPicker_New
public WheelPicker_New(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);
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);
// 更新文本对齐方式
// 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();
}
示例8: init
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();
}