当前位置: 首页>>代码示例>>Java>>正文


Java BoringLayout.draw方法代码示例

本文整理汇总了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);

    }
 
开发者ID:blazsolar,项目名称:WeekDatePicker,代码行数:46,代码来源:WeekDatePicker.java

示例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);
}
 
开发者ID:iOnesmile,项目名称:CustomEQView,代码行数:76,代码来源:HorizontalPicker.java


注:本文中的android.text.BoringLayout.draw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。