本文整理汇总了Java中android.text.BoringLayout.draw方法的典型用法代码示例。如果您正苦于以下问题:Java BoringLayout.draw方法的具体用法?Java BoringLayout.draw怎么用?Java BoringLayout.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.text.BoringLayout
的用法示例。
在下文中一共展示了BoringLayout.draw方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawWeek
import android.text.BoringLayout; //导入方法依赖的package包/类
private void drawWeek(Canvas canvas, int layoutIndex, int weekOffset) {
int saveCount = canvas.save();
int labelHeight = dayLabelLayouts[0].getHeight();
float circleRadius = dayWidth / 3;
int centerY = layouts[0].getHeight() / 2;
float dateLineOffset = circleRadius - centerY;
for (int i = 0; i < 7; i++) {
int itemIndex = weekOffset * 7 + i;
BoringLayout layout = layouts[layoutIndex + i];
BoringLayout labelLayout = dayLabelLayouts[i];
dayLabelTextPain.setColor(getTextColor(dayLabelTextColor, itemIndex));
labelLayout.draw(canvas);
dayTextPaint.setColor(getTextColor(dayTextColor, itemIndex));
int count = canvas.save();
canvas.translate(0, labelHeight + dateLineOffset + labelPadding);
if (dayDrawable != null) {
dayDrawable.setBounds(backgroundRect);
dayDrawable.setState(getItemDrawableState(itemIndex));
dayDrawable.draw(canvas);
}
if (indicatorDrawable != null && dayIndicators.get(itemIndex - dayDelta, false)) {
indicatorDrawable.setBounds(indicatorRect);
indicatorDrawable.setState(getItemDrawableState(itemIndex));
indicatorDrawable.draw(canvas);
}
layout.draw(canvas);
canvas.restoreToCount(count);
canvas.translate(dayWidth, 0);
}
canvas.restoreToCount(saveCount);
}
示例2: onDraw
import android.text.BoringLayout; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
int saveCount = canvas.getSaveCount();
canvas.save();
int selectedItem = this.selectedItem;
float itemWithPadding = itemWidth + dividerSize;
// translate horizontal to center
canvas.translate(itemWithPadding * sideItems, 0);
if (values != null) {
for (int i = 0; i < values.length; i++) {
// set text color for item
textPaint.setColor(getTextColor(i));
textPaint.setTextSize(getTextSize(i));
// get text layout
BoringLayout layout = layouts[i];
int saveCountHeight = canvas.getSaveCount();
canvas.save();
float x = 0;
float lineWidth = layout.getLineWidth(0);
if (lineWidth > itemWidth) {
if (isRtl(values[i])) {
x += (lineWidth - itemWidth) / 2;
} else {
x -= (lineWidth - itemWidth) / 2;
}
}
if (marquee != null && i == selectedItem) {
x += marquee.getScroll();
}
// translate vertically to center
canvas.translate(-x, (canvas.getHeight() - layout.getHeight()) / 2);
RectF clipBounds;
if (x == 0) {
clipBounds = itemClipBounds;
} else {
clipBounds = itemClipBoundsOffset;
clipBounds.set(itemClipBounds);
clipBounds.offset(x, 0);
}
canvas.clipRect(clipBounds);
layout.draw(canvas);
if (marquee != null && i == selectedItem && marquee.shouldDrawGhost()) {
canvas.translate(marquee.getGhostOffset(), 0);
layout.draw(canvas);
}
// restore vertical translation
canvas.restoreToCount(saveCountHeight);
// translate horizontal for 1 item
canvas.translate(itemWithPadding, 0);
}
}
// restore horizontal translation
canvas.restoreToCount(saveCount);
drawEdgeEffect(canvas, leftEdgeEffect, 270);
drawEdgeEffect(canvas, rightEdgeEffect, 90);
}