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


Java CanvasWatchFaceService类代码示例

本文整理汇总了Java中android.support.wearable.watchface.CanvasWatchFaceService的典型用法代码示例。如果您正苦于以下问题:Java CanvasWatchFaceService类的具体用法?Java CanvasWatchFaceService怎么用?Java CanvasWatchFaceService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CanvasWatchFaceService类属于android.support.wearable.watchface包,在下文中一共展示了CanvasWatchFaceService类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawViewModelOnCanvas

import android.support.wearable.watchface.CanvasWatchFaceService; //导入依赖的package包/类
public void drawViewModelOnCanvas(final WatchFaceViewModel viewModel, final Canvas canvas, final Rect bounds, final CanvasWatchFaceService.Engine engine) {
    // draw background
    backgroundPaint.setColor(engine.isInAmbientMode() ? ambientBgColor : interactiveBgColor);
    canvas.drawRect(0, 0, bounds.width(), bounds.height(), backgroundPaint);

    // draw time
    int baseX = bounds.centerX();
    int baseY = bounds.centerY();
    baseY -= distanceHourMinute*2;

    Rect hourBounds = new Rect();
    timePaint.getTextBounds(viewModel.hourString, 0, viewModel.hourString.length(), hourBounds);

    Rect minuteBounds = new Rect();
    timePaint.getTextBounds(viewModel.minuteString, 0, viewModel.minuteString.length(), minuteBounds);

    Rect bitcoinPriceBounds = new Rect();
    bitcoinPricePaint.getTextBounds(viewModel.bitcoinPriceString, 0, viewModel.bitcoinPriceString.length(), bitcoinPriceBounds);

    int timeX = baseX - minuteBounds.width() / 2;
    float hourY = baseY - distanceHourMinute / 2;
    float minuteY = baseY + minuteBounds.height() + distanceHourMinute / 2;

    float bitcoinIconX = baseX - (bitcoinPriceBounds.width() + bitcoinIconSize) / 2;

    canvas.drawText(viewModel.hourString, timeX, hourY, timePaint);
    canvas.drawText(viewModel.minuteString, timeX, minuteY, timePaint);

    // draw bitcoin price
    float magicalOffsetToAlignTextWithIcon = distanceHourMinute / 2;
    int baseYPrice = bounds.bottom;
    baseYPrice -= distanceHourMinute*2;
    canvas.drawBitmap(bitcoinIcon, bitcoinIconX, baseYPrice - bitcoinIconSize * 2 + magicalOffsetToAlignTextWithIcon, new Paint());
    canvas.drawText(viewModel.bitcoinPriceString, bitcoinIconX + bitcoinIconSize, baseYPrice - bitcoinIconSize, bitcoinPricePaint);
}
 
开发者ID:tobiasheine,项目名称:BitcoinWatcher,代码行数:36,代码来源:WatchFaceDrawer.java

示例2: onCreateEngine

import android.support.wearable.watchface.CanvasWatchFaceService; //导入依赖的package包/类
@Override
public CanvasWatchFaceService.Engine onCreateEngine() {
    return new Engine();
}
 
开发者ID:jimmykane,项目名称:Athletica,代码行数:5,代码来源:WatchFaceService.java

示例3: WatchFaceTimer

import android.support.wearable.watchface.CanvasWatchFaceService; //导入依赖的package包/类
public WatchFaceTimer(CanvasWatchFaceService.Engine engine, Storage storage, GoogleApiClient googleApiClient) {
    this.engine = engine;
    this.storage = storage;

    this.googleApiClient = googleApiClient;
}
 
开发者ID:tobiasheine,项目名称:BitcoinWatcher,代码行数:7,代码来源:WatchFaceTimer.java


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